Daniel Kinzler has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/167224

Change subject: Defer entity deserialization.
......................................................................

Defer entity deserialization.

This introduces EntityHolders which are used by EntityContent
as placeholders for not-yet-deserialized entities. This should
avoid averhead especially for creating deep copies.

Change-Id: I51f3d5860859c25acfb535d4a5725ceced9c090b
---
A repo/includes/content/DeferredCopyEntityHolder.php
A repo/includes/content/DeferredDecodingEntityHolder.php
M repo/includes/content/EntityContent.php
M repo/includes/content/EntityContentFactory.php
M repo/includes/content/EntityHandler.php
A repo/includes/content/EntityHolder.php
A repo/includes/content/EntityInstanceHolder.php
M repo/includes/content/ItemContent.php
M repo/includes/content/PropertyContent.php
M repo/tests/phpunit/includes/content/EntityHandlerTest.php
M repo/tests/phpunit/includes/content/ItemHandlerTest.php
11 files changed, 416 insertions(+), 56 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/24/167224/2

diff --git a/repo/includes/content/DeferredCopyEntityHolder.php 
b/repo/includes/content/DeferredCopyEntityHolder.php
new file mode 100644
index 0000000..2c1302b
--- /dev/null
+++ b/repo/includes/content/DeferredCopyEntityHolder.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Wikibase\Content;
+
+use RuntimeException;
+use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityId;
+
+/**
+ * EntityHolder implementing deferred copying.
+ *
+ * @license GPL 2+
+ * @author Daniel Kinzler
+ */
+class DeferredCopyEntityHolder implements EntityHolder {
+
+       /**
+        * @var EntityHolder
+        */
+       private $entityHolder;
+
+       /**
+        * @var Entity
+        */
+       private $entity = null;
+
+       /**
+        * @param EntityHolder $entityHolder
+        */
+       public function __construct( EntityHolder $entityHolder ) {
+               $this->entityHolder = $entityHolder;
+       }
+
+       /**
+        * @see EntityHolder::getEntityId
+        *
+        * This implements lazy initialization of the entity: when called for 
the first time,
+        * this method will call getEntity() on the EntityHolder passed to the 
constructor,
+        * and then calls copy() on the entity returned. The resulting copy is 
returned.
+        * Subsequent calls will return the same entity.
+        *
+        * @param string $expectedClass The class the result is expected to be 
compatible with.
+        * Defaults to Entity.
+        *
+        * @throws RuntimeException If the entity held by this EntityHolder is 
not compatible with $expectedClass.
+        * @return Entity
+        */
+       public function getEntity( $expectedClass = 
'Wikibase\DataModel\Entity\Entity' ) {
+               if ( !$this->entity ) {
+                       $entity = $this->entityHolder->getEntity( 
$expectedClass );
+                       $this->entity = $entity->copy();
+               }
+
+               return $this->entity;
+       }
+
+       /**
+        * @see EntityHolder::getEntityId
+        *
+        * @return EntityId|null
+        */
+       public function getEntityId() {
+               return $this->entityHolder->getEntityId();
+       }
+
+       /**
+        * @see EntityHolder::getEntityType
+        *
+        * @return string
+        */
+       public function getEntityType() {
+               return $this->entityHolder->getEntityType();
+       }
+
+}
+ 
\ No newline at end of file
diff --git a/repo/includes/content/DeferredDecodingEntityHolder.php 
b/repo/includes/content/DeferredDecodingEntityHolder.php
new file mode 100644
index 0000000..08af376
--- /dev/null
+++ b/repo/includes/content/DeferredDecodingEntityHolder.php
@@ -0,0 +1,123 @@
+<?php
+
+namespace Wikibase\Content;
+
+use InvalidArgumentException;
+use RuntimeException;
+use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\Lib\Store\EntityContentDataCodec;
+
+/**
+ * EntityHolder implementing deferred deserialization.
+ *
+ * @license GPL 2+
+ * @author Daniel Kinzler
+ */
+class DeferredDecodingEntityHolder implements EntityHolder {
+
+       /**
+        * @var Entity
+        */
+       private $entity = null;
+
+       /**
+        * @var EntityContentDataCodec
+        */
+       private $codec;
+
+       /**
+        * @var string
+        */
+       private $blob;
+
+       /**
+        * @var null
+        */
+       private $format;
+
+       /**
+        * @var string
+        */
+       private $entityType;
+
+       /**
+        * @var EntityId
+        */
+       private $entityId;
+
+       /**
+        * @param EntityContentDataCodec $codec
+        * @param string $blob
+        * @param string $format
+        * @param $entityType
+        * @param EntityId $entityId
+        *
+        * @throws InvalidArgumentException
+        */
+       public function __construct( EntityContentDataCodec $codec, $blob, 
$format, $entityType, EntityId $entityId = null ) {
+               if ( !is_string( $blob ) ) {
+                       throw new InvalidArgumentException( '$blob must be a 
string' );
+               }
+
+               if ( !is_string( $format ) ) {
+                       throw new InvalidArgumentException( '$format must be a 
string' );
+               }
+
+               if ( !is_string( $entityType ) ) {
+                       throw new InvalidArgumentException( '$entityType must 
be a string' );
+               }
+
+               $this->codec = $codec;
+               $this->blob = $blob;
+               $this->format = $format;
+               $this->entityType = $entityType;
+               $this->entityId = $entityId;
+       }
+
+       /**
+        * @see EntityHolder::getEntityId
+        *
+        * This implements lazy initialization of the entity: when called for 
the first time,
+        * this method will call getEntity() on the EntityHolder passed to the 
constructor,
+        * and then calls copy() on the entity returned. The resulting copy is 
returned.
+        * Subsequent calls will return the same entity.
+        *
+        * @param string $expectedClass The class the result is expected to be 
compatible with.
+        * Defaults to Entity.
+        *
+        * @throws RuntimeException If the entity held by this EntityHolder is 
not compatible with $expectedClass.
+        * @return Entity
+        */
+       public function getEntity( $expectedClass = 
'Wikibase\DataModel\Entity\Entity' ) {
+               if ( !$this->entity ) {
+                       $this->entity = $this->codec->decodeEntity( 
$this->blob, $this->format );
+               }
+
+               return $this->entity;
+       }
+
+       /**
+        * @see EntityHolder::getEntityId
+        *
+        * @return EntityId|null
+        */
+       public function getEntityId() {
+               if ( !$this->entityId ) {
+                       $this->entityId = $this->getEntity()->getId();
+               }
+
+               return $this->entityId;
+       }
+
+       /**
+        * @see EntityHolder::getEntityType
+        *
+        * @return string
+        */
+       public function getEntityType() {
+               return $this->entityType;
+       }
+
+}
+ 
\ No newline at end of file
diff --git a/repo/includes/content/EntityContent.php 
b/repo/includes/content/EntityContent.php
index 8385055..43adb9a 100644
--- a/repo/includes/content/EntityContent.php
+++ b/repo/includes/content/EntityContent.php
@@ -23,6 +23,9 @@
 use User;
 use ValueFormatters\FormatterOptions;
 use ValueFormatters\ValueFormatter;
+use Wikibase\Content\DeferredCopyEntityHolder;
+use Wikibase\Content\EntityHolder;
+use Wikibase\Content\EntityInstanceHolder;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\Lib\Serializers\SerializationOptions;
@@ -90,7 +93,7 @@
                        return $this->getContentHandler()->supportsRedirects();
                }
 
-               return $this->getEntity()->getId() !== null;
+               return $this->getEntityId() !== null;
        }
 
        /**
@@ -122,6 +125,14 @@
        abstract public function getEntity();
 
        /**
+        * Returns a holder for the entity contained in this EntityContent 
object.
+        *
+        * @throws MWException when it's a redirect (targets will never be 
resolved)
+        * @return EntityHolder
+        */
+       abstract protected function getEntityHolder();
+
+       /**
         * Returns the ID of the entity represented by this EntityContent;
         *
         * @throws RuntimeException if no entity ID is set
@@ -131,13 +142,14 @@
                if ( $this->isRedirect() ) {
                        return $this->getEntityRedirect()->getEntityId();
                } else {
-                       if ( !$this->getEntity()->getId() ) {
+                       $id = $this->getEntityHolder()->getEntityId();
+                       if ( !$id ) {
                                // @todo: Force an ID to be present; Entity 
objects without an ID make sense,
                                // EntityContent objects with no entity ID 
don't.
                                throw new RuntimeException( 'EntityContent was 
constructed without an EntityId!' );
                        }
 
-                       return $this->getEntity()->getId();
+                       return $id;
                }
        }
 
@@ -627,17 +639,17 @@
                        return false;
                }
 
-               $thisEntity = $this->getEntity();
-               $thatEntity = $that->getEntity();
-
-               $thisId = $thisEntity->getId();
-               $thatId = $thatEntity->getId();
+               $thisId = $this->getEntityHolder()->getEntityId();
+               $thatId = $that->getEntityHolder()->getEntityId();
 
                if ( $thisId !== null && $thatId !== null
                        && !$thisId->equals( $thatId )
                ) {
                        return false;
                }
+
+               $thisEntity = $this->getEntity();
+               $thatEntity = $that->getEntity();
 
                return $thisEntity->equals( $thatEntity );
        }
@@ -710,7 +722,7 @@
                                        . $this->getModel() . '!' );
                        }
                } else {
-                       $patched = $handler->makeEntityContent( 
$entityAfterPatch );
+                       $patched = $handler->makeEntityContent( new 
EntityInstanceHolder( $entityAfterPatch ) );
                }
 
                return $patched;
@@ -782,7 +794,7 @@
                if ( $this->isRedirect() ) {
                        return $handler->makeEntityRedirectContent( 
$this->getEntityRedirect() );
                } else {
-                       return $handler->makeEntityContent( 
$this->getEntity()->copy() );
+                       return $handler->makeEntityContent( new 
DeferredCopyEntityHolder( $this->getEntityHolder() ) );
                }
        }
 
diff --git a/repo/includes/content/EntityContentFactory.php 
b/repo/includes/content/EntityContentFactory.php
index 218c43a..9f8991b 100644
--- a/repo/includes/content/EntityContentFactory.php
+++ b/repo/includes/content/EntityContentFactory.php
@@ -9,8 +9,10 @@
 use Status;
 use Title;
 use User;
+use Wikibase\Content\EntityInstanceHolder;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\EntityContent;
 use Wikibase\Lib\Store\EntityRedirect;
 use Wikibase\Lib\Store\EntityTitleLookup;
 use Wikibase\Repo\Store\EntityPermissionChecker;
@@ -168,7 +170,7 @@
         */
        public function newFromEntity( Entity $entity ) {
                $handler = $this->getContentHandlerForType( $entity->getType() 
);
-               return $handler->makeEntityContent( $entity );
+               return $handler->makeEntityContent( new EntityInstanceHolder( 
$entity ) );
        }
 
        /**
diff --git a/repo/includes/content/EntityHandler.php 
b/repo/includes/content/EntityHandler.php
index 65459c6..e3a0cf0 100644
--- a/repo/includes/content/EntityHandler.php
+++ b/repo/includes/content/EntityHandler.php
@@ -18,6 +18,8 @@
 use Title;
 use User;
 use ValueValidators\Result;
+use Wikibase\Content\DeferredDecodingEntityHolder;
+use Wikibase\Content\EntityHolder;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParser;
@@ -300,18 +302,17 @@
        /**
         * Creates a Content object for the given Entity object.
         *
-        * @since 0.4
+        * @since 0.5
         *
-        * @param Entity $entity
+        * @param EntityHolder $entityHolder
         *
-        * @throws InvalidArgumentException
         * @return EntityContent
         */
-       public function makeEntityContent( Entity $entity ) {
+       public function makeEntityContent( EntityHolder $entityHolder ) {
                $contentClass = $this->getContentClass();
 
                /* EntityContent $content */
-               $content = new $contentClass( $entity );
+               $content = new $contentClass( $entityHolder );
 
                //TODO: make sure the entity is valid/complete!
 
@@ -355,31 +356,25 @@
                        $redirect = $content->getEntityRedirect();
                        return $this->contentCodec->encodeRedirect( $redirect, 
$format );
                } else {
+                       //TODO: if we have an un-decoded Entity in a 
DeferredDecodingEntityHolder, just re-use the encoded form.
                        $entity = $content->getEntity();
                        return $this->contentCodec->encodeEntity( $entity, 
$format );
                }
        }
 
-
        /**
         * @see ContentHandler::unserializeContent
         *
         * @param string $blob
-        * @param null|string $format
+        * @param string $format
         *
         * @throws MWContentSerializationException
         * @return EntityContent
         */
-       public function unserializeContent( $blob, $format = null ) {
-               $entity = $this->contentCodec->decodeEntity( $blob, $format );
+       public function unserializeContent( $blob, $format = 
CONTENT_FORMAT_JSON ) {
+               $redirect = $this->contentCodec->decodeRedirect( $blob, $format 
);
 
-               if ( $entity ) {
-                       $entityContent = $this->makeEntityContent( $entity );
-                       return $entityContent;
-               } else {
-                       // Must be a redirect then
-                       $redirect = $this->contentCodec->decodeRedirect( $blob, 
$format );
-
+               if ( $redirect ) {
                        if ( $redirect === null ) {
                                throw new MWContentSerializationException(
                                        'The serialized data contains neither 
an Entity nor an EntityRedirect!'
@@ -387,6 +382,11 @@
                        }
 
                        return $this->makeEntityRedirectContent( $redirect );
+               } else {
+                       $holder = new DeferredDecodingEntityHolder( 
$this->contentCodec, $blob, $format, $this->getEntityType() );
+                       $entityContent = $this->makeEntityContent( $holder );
+
+                       return $entityContent;
                }
        }
 
diff --git a/repo/includes/content/EntityHolder.php 
b/repo/includes/content/EntityHolder.php
new file mode 100644
index 0000000..07e1727
--- /dev/null
+++ b/repo/includes/content/EntityHolder.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Wikibase\Content;
+
+use RuntimeException;
+use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityId;
+
+/**
+ * A holder for entities.
+ *
+ * @license GPL 2+
+ * @author Daniel Kinzler
+ */
+interface EntityHolder {
+
+       /**
+        * Returns the entity held by this EntityHolder.
+        * Depending on the implementation, this operation may be expensive or 
trivial.
+        *
+        * @param string $expectedClass The class the result is expected to be 
compatible with.
+        * Defaults to Entity.
+        *
+        * @throws RuntimeException If the entity held by this EntityHolder is 
not compatible with $expectedClass.
+        * @return Entity
+        */
+       public function getEntity( $expectedClass = 
'Wikibase\DataModel\Entity\Entity' );
+
+       /**
+        * Returns the ID of the entity held by this EntityHolder.
+        * May or may not require the actual entity to be instantiated.
+        * May be null if the Entity does not have an ID set.
+        *
+        * @return EntityId|null
+        */
+       public function getEntityId();
+
+       /**
+        * Returns the type of the entity held by this EntityHolder.
+        * May or may not require the actual entity or the entity's ID to be 
instantiated.
+        * Implementations must make sure that this is never null.
+        *
+        * @return string
+        */
+       public function getEntityType();
+
+}
+ 
\ No newline at end of file
diff --git a/repo/includes/content/EntityInstanceHolder.php 
b/repo/includes/content/EntityInstanceHolder.php
new file mode 100644
index 0000000..b09d59e
--- /dev/null
+++ b/repo/includes/content/EntityInstanceHolder.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Wikibase\Content;
+
+use RuntimeException;
+use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Entity\EntityId;
+
+/**
+ * Trivial EntityHolder holding an Entity object.
+ *
+ * @license GPL 2+
+ * @author Daniel Kinzler
+ */
+class EntityInstanceHolder implements EntityHolder {
+
+       /**
+        * @var Entity
+        */
+       private $entity;
+
+       /**
+        * @param Entity $entity
+        */
+       public function __construct( Entity $entity ) {
+               $this->entity = $entity;
+       }
+
+       /**
+        * @see EntityHolder::getEntityId
+        *
+        * @param string $expectedClass The class the result is expected to be 
compatible with.
+        * Defaults to Entity.
+        *
+        * @throws RuntimeException If the entity held by this EntityHolder is 
not compatible with $expectedClass.
+        * @return Entity
+        */
+       public function getEntity( $expectedClass = 
'Wikibase\DataModel\Entity\Entity' ) {
+               if ( !( $this->entity instanceof $expectedClass ) ) {
+                       throw new RuntimeException( 'Contained entity is not 
compatible with ' . $expectedClass );
+               }
+
+               return $this->entity;
+       }
+
+       /**
+        * @see EntityHolder::getEntityId
+        *
+        * @return EntityId|null
+        */
+       public function getEntityId() {
+               return $this->entity->getId();
+       }
+
+       /**
+        * @see EntityHolder::getEntityType
+        *
+        * @return string
+        */
+       public function getEntityType() {
+               return $this->entity->getType();
+       }
+
+}
+ 
\ No newline at end of file
diff --git a/repo/includes/content/ItemContent.php 
b/repo/includes/content/ItemContent.php
index 11359d0..437987a 100644
--- a/repo/includes/content/ItemContent.php
+++ b/repo/includes/content/ItemContent.php
@@ -6,7 +6,11 @@
 use Language;
 use LogicException;
 use MWException;
+use RuntimeException;
 use Title;
+use Wikibase\Content\EntityHolder;
+use Wikibase\Content\EntityInstanceHolder;
+use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\Item;
 use Wikibase\Lib\Store\EntityRedirect;
 use Wikibase\Repo\ItemSearchTextGenerator;
@@ -53,22 +57,26 @@
         * In other words: treat as protected (which it was, but now cannot
         * be since we derive from Content).
         *
-        * @param Item|null $item
+        * @param EntityHolder|null $itemHolder
         * @param EntityRedirect|null $entityRedirect
         * @param Title|null $redirectTitle
         *
         * @throws InvalidArgumentException
         */
        public function __construct(
-               Item $item = null,
+               EntityHolder $itemHolder = null,
                EntityRedirect $entityRedirect = null,
                Title $redirectTitle = null
        ) {
                parent::__construct( CONTENT_MODEL_WIKIBASE_ITEM );
 
-               if ( is_null( $item ) === is_null( $entityRedirect ) ) {
+               if ( is_null( $itemHolder ) === is_null( $entityRedirect ) ) {
                        throw new InvalidArgumentException(
                                'Either $item or $entityRedirect and 
$redirectTitle must be provided.' );
+               }
+
+               if ( $itemHolder !== null && $itemHolder->getEntityType() !== 
Item::ENTITY_TYPE ) {
+                       throw new InvalidArgumentException( '$itemHolder must 
contain a Item entity!' );
                }
 
                if ( is_null( $entityRedirect ) !== is_null( $redirectTitle ) ) 
{
@@ -86,7 +94,7 @@
                        }
                }
 
-               $this->item = $item;
+               $this->itemHolder = $itemHolder;
                $this->redirect = $entityRedirect;
                $this->redirectTitle = $redirectTitle;
        }
@@ -99,7 +107,7 @@
         * @return ItemContent
         */
        public static function newFromItem( Item $item ) {
-               return new static( $item );
+               return new static( new EntityInstanceHolder( $item ) );
        }
 
        /**
@@ -148,11 +156,16 @@
                        throw new MWException( 'Unresolved redirect to [[' . 
$redirect->getFullText() . ']]' );
                }
 
-               if ( !$this->item ) {
+               if ( !$this->itemHolder ) {
                        throw new LogicException( 'Neither redirect nor item 
found in ItemContent!' );
                }
 
-               return $this->item;
+               wfProfileIn( __METHOD__ );
+
+               $item = $this->itemHolder->getEntity( 
'Wikibase\DataModel\Entity\Item' );
+
+               wfProfileOut( __METHOD__ );
+               return $item;
        }
 
        /**
@@ -161,7 +174,7 @@
         * @return ItemContent
         */
        public static function newEmpty() {
-               return new static( Item::newEmpty() );
+               return new static( new EntityInstanceHolder( Item::newEmpty() ) 
);
        }
 
        /**
@@ -175,6 +188,15 @@
        }
 
        /**
+        * @see EntityContent::getEntityHolder
+        *
+        * @return EntityHolder
+        */
+       protected function getEntityHolder() {
+               return $this->itemHolder;
+       }
+
+       /**
         * @see EntityContent::getTextForSearchIndex()
         */
        public function getTextForSearchIndex() {
diff --git a/repo/includes/content/PropertyContent.php 
b/repo/includes/content/PropertyContent.php
index 7a35fcc..f0c301a 100644
--- a/repo/includes/content/PropertyContent.php
+++ b/repo/includes/content/PropertyContent.php
@@ -2,7 +2,10 @@
 
 namespace Wikibase;
 
+use InvalidArgumentException;
 use Language;
+use Wikibase\Content\EntityHolder;
+use Wikibase\Content\EntityInstanceHolder;
 use Wikibase\DataModel\Entity\Property;
 use Wikibase\Repo\View\ClaimsView;
 use Wikibase\Repo\View\FingerprintView;
@@ -18,9 +21,9 @@
 class PropertyContent extends EntityContent {
 
        /**
-        * @var Property
+        * @var EntityHolder
         */
-       private $property;
+       private $propertyHolder;
 
        /**
         * Do not use to construct new stuff from outside of this class,
@@ -31,11 +34,17 @@
         *
         * @protected
         *
-        * @param Property $property
+        * @param EntityHolder $propertyHolder
+        * @throws InvalidArgumentException
         */
-       public function __construct( Property $property ) {
+       public function __construct( EntityHolder $propertyHolder ) {
                parent::__construct( CONTENT_MODEL_WIKIBASE_PROPERTY );
-               $this->property = $property;
+
+               if ( $propertyHolder->getEntityType() !== Property::ENTITY_TYPE 
) {
+                       throw new InvalidArgumentException( '$propertyHolder 
must contain a Property entity!' );
+               }
+
+               $this->propertyHolder = $propertyHolder;
        }
 
        /**
@@ -46,7 +55,7 @@
         * @return PropertyContent
         */
        public static function newFromProperty( Property $property ) {
-               return new static( $property );
+               return new static( new EntityInstanceHolder( $property ) );
        }
 
        /**
@@ -55,16 +64,7 @@
         * @return Property
         */
        public function getProperty() {
-               return $this->property;
-       }
-
-       /**
-        * Sets the property that makes up this property content.
-        *
-        * @param Property $property
-        */
-       public function setProperty( Property $property ) {
-               $this->property = $property;
+               return $this->propertyHolder->getEntity( 
'Wikibase\DataModel\Entity\Property' );
        }
 
        /**
@@ -73,7 +73,7 @@
         * @return PropertyContent
         */
        public static function newEmpty() {
-               return new static( Property::newFromType( 'string' ) );
+               return new static( new EntityInstanceHolder( 
Property::newFromType( 'string' ) ) );
        }
 
        /**
@@ -82,7 +82,16 @@
         * @return Property
         */
        public function getEntity() {
-               return $this->property;
+               return $this->getProperty();
+       }
+
+       /**
+        * @see EntityContent::getEntityHolder
+        *
+        * @return EntityHolder
+        */
+       public function getEntityHolder() {
+               return $this->propertyHolder;
        }
 
        /**
@@ -97,6 +106,7 @@
                        return false;
                }
 
+               //TODO: provide a way to get the data type from the holder 
directly!
                if ( is_null( $this->getEntity()->getDataTypeId() ) ) {
                        return false;
                }
diff --git a/repo/tests/phpunit/includes/content/EntityHandlerTest.php 
b/repo/tests/phpunit/includes/content/EntityHandlerTest.php
index 9786c34..fc68759 100644
--- a/repo/tests/phpunit/includes/content/EntityHandlerTest.php
+++ b/repo/tests/phpunit/includes/content/EntityHandlerTest.php
@@ -8,6 +8,7 @@
 use Revision;
 use RuntimeException;
 use Title;
+use Wikibase\Content\EntityInstanceHolder;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\EntityContent;
@@ -79,7 +80,7 @@
                }
 
                $handler = $this->getHandler();
-               return $handler->makeEntityContent( $entity );
+               return $handler->makeEntityContent( new EntityInstanceHolder( 
$entity ) );
        }
 
        /**
@@ -305,7 +306,7 @@
                $entity = $this->newEntity();
 
                $handler = $this->getHandler();
-               $content = $handler->makeEntityContent( $entity );
+               $content = $handler->makeEntityContent( new 
EntityInstanceHolder( $entity ) );
 
                $this->assertEquals( $this->getModelId(), $content->getModel() 
);
                $this->assertSame( $entity, $content->getEntity() );
diff --git a/repo/tests/phpunit/includes/content/ItemHandlerTest.php 
b/repo/tests/phpunit/includes/content/ItemHandlerTest.php
index 118fc72..242ea96 100644
--- a/repo/tests/phpunit/includes/content/ItemHandlerTest.php
+++ b/repo/tests/phpunit/includes/content/ItemHandlerTest.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Test;
 
+use Wikibase\Content\EntityInstanceHolder;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\Item;
@@ -102,7 +103,7 @@
                        $entity->setId( new ItemId( 'Q42' ) );
                }
 
-               return $this->getHandler()->makeEntityContent( $entity );
+               return $this->getHandler()->makeEntityContent( new 
EntityInstanceHolder( $entity ) );
        }
 
        public function testMakeEntityRedirectContent() {

-- 
To view, visit https://gerrit.wikimedia.org/r/167224
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51f3d5860859c25acfb535d4a5725ceced9c090b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to