Addshore has uploaded a new change for review.

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


Change subject: Get rid of use of EntityContentFactory singleton
......................................................................

Get rid of use of EntityContentFactory singleton

Change-Id: I9f0a0144e1d3187474814dfbf8b5833057dac88d
---
M lib/includes/specials/SpecialWikibaseQueryPage.php
M lib/tests/phpunit/store/WikiPageEntityLookupTest.php
M repo/Wikibase.hooks.php
M repo/includes/ClaimSaver.php
M repo/includes/EditEntity.php
M repo/includes/LinkedData/EntityDataRequestHandler.php
M repo/includes/Summary.php
M repo/includes/actions/ViewEntityAction.php
M repo/includes/api/ClaimModificationHelper.php
M repo/includes/api/GetClaims.php
M repo/includes/api/GetEntities.php
M repo/includes/api/SearchEntities.php
M repo/includes/content/EntityContent.php
M repo/includes/content/ItemContent.php
M repo/includes/content/ItemHandler.php
M repo/includes/specials/SpecialEntityData.php
M repo/includes/specials/SpecialItemDisambiguation.php
M repo/includes/specials/SpecialModifyEntity.php
M repo/includes/store/sql/SqlStore.php
M repo/maintenance/rebuildEntityPerPage.php
M repo/maintenance/searchEntityArtefacts.php
M repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
M repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
M repo/tests/phpunit/includes/api/RemoveClaimsTest.php
M repo/tests/phpunit/includes/api/SetClaimValueTest.php
M repo/tests/phpunit/includes/api/SetQualifierTest.php
M repo/tests/phpunit/includes/api/SetStatementRankTest.php
M repo/tests/phpunit/includes/content/EntityContentFactoryTest.php
M repo/tests/phpunit/includes/content/EntityHandlerTest.php
M repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
30 files changed, 96 insertions(+), 50 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/34/87534/1

diff --git a/lib/includes/specials/SpecialWikibaseQueryPage.php 
b/lib/includes/specials/SpecialWikibaseQueryPage.php
index 2630624..3ef5137 100644
--- a/lib/includes/specials/SpecialWikibaseQueryPage.php
+++ b/lib/includes/specials/SpecialWikibaseQueryPage.php
@@ -7,6 +7,7 @@
 use MWException;
 use Title;
 use Wikibase\EntityContentFactory;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Base for special pages that show the result of a Query. Rewriting of 
QueryPage but
@@ -82,7 +83,7 @@
         */
        protected function formatRow( $entry ) {
                try {
-                       $title = 
EntityContentFactory::singleton()->getTitleForId( $entry );
+                       $title = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getTitleForId( 
$entry );
                        return Linker::linkKnown( $title );
                } catch ( MWException $e ) {
                        wfWarn( "Error formatting result row: " . 
$e->getMessage() );
diff --git a/lib/tests/phpunit/store/WikiPageEntityLookupTest.php 
b/lib/tests/phpunit/store/WikiPageEntityLookupTest.php
index e13e73f..8a55046 100644
--- a/lib/tests/phpunit/store/WikiPageEntityLookupTest.php
+++ b/lib/tests/phpunit/store/WikiPageEntityLookupTest.php
@@ -7,6 +7,7 @@
 use Wikibase\EntityContentFactory;
 use Wikibase\EntityLookup;
 use Wikibase\EntityRevision;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\WikiPageEntityLookup;
 
 /**
@@ -68,7 +69,7 @@
                }
 
                // FIXME: this is using repo functionality
-               $content = EntityContentFactory::singleton()->newFromEntity( 
$entity );
+               $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->newFromEntity( 
$entity );
                $status = $content->save( "storeTestEntity" );
 
                if ( !$status->isOK() ) {
diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index 91350e7..29e0833 100644
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -211,7 +211,9 @@
        public static function onNewRevisionFromEditComplete( $article, 
Revision $revision, $baseID, User $user ) {
                wfProfileIn( __METHOD__ );
 
-               if ( EntityContentFactory::singleton()->isEntityContentModel( 
$article->getContent()->getModel() ) ) {
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
+               if ( $entityContentFactory->isEntityContentModel( 
$article->getContent()->getModel() ) ) {
                        /**
                         * @var $newEntity Entity
                         */
@@ -263,7 +265,7 @@
        ) {
                wfProfileIn( __METHOD__ );
 
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
 
                // Bail out if we are not looking at an entity
                if ( !$content || !$entityContentFactory->isEntityContentModel( 
$content->getModel() ) ) {
@@ -307,7 +309,7 @@
        public static function onArticleUndelete( Title $title, $created, 
$comment ) {
                wfProfileIn( __METHOD__ );
 
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
 
                // Bail out if we are not looking at an entity
                if ( !$entityContentFactory->isEntityContentModel( 
$title->getContentModel() ) ) {
@@ -442,10 +444,12 @@
        public static function onPageHistoryLineEnding( \HistoryPager $history, 
&$row, &$s, array &$classes  ) {
                wfProfileIn( __METHOD__ );
 
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
                $article = $history->getArticle();
                $rev = new Revision( $row );
 
-               if ( EntityContentFactory::singleton()->isEntityContentModel( 
$history->getTitle()->getContentModel() )
+               if ( $entityContentFactory->isEntityContentModel( 
$history->getTitle()->getContentModel() )
                        && $article->getPage()->getLatest() !== $rev->getID()
                        && $rev->getTitle()->quickUserCan( 'edit', 
$history->getUser() )
                ) {
@@ -480,10 +484,12 @@
        public static function onPageTabs( \SkinTemplate &$sktemplate, array 
&$links ) {
                wfProfileIn( __METHOD__ );
 
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
                $title = $sktemplate->getTitle();
                $request = $sktemplate->getRequest();
 
-               if ( EntityContentFactory::singleton()->isEntityContentModel( 
$title->getContentModel() ) ) {
+               if ( $entityContentFactory->isEntityContentModel( 
$title->getContentModel() ) ) {
                        unset( $links['views']['edit'] );
                        unset( $links['views']['viewsource'] );
 
@@ -631,7 +637,9 @@
        public static function onOutputPageBodyAttributes( \OutputPage $out, 
\Skin $sk, array &$bodyAttrs ) {
                wfProfileIn( __METHOD__ );
 
-               if ( EntityContentFactory::singleton()->isEntityContentModel( 
$out->getTitle()->getContentModel() ) ) {
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
+               if ( $entityContentFactory->isEntityContentModel( 
$out->getTitle()->getContentModel() ) ) {
                        // we only add the classes, if there is an actual item 
and not just an empty Page in the right namespace
                        $entityPage = new WikiPage( $out->getTitle() );
                        $entityContent = $entityPage->getContent();
@@ -678,9 +686,11 @@
        public static function onLinkBegin( $skin, $target, &$html, array 
&$customAttribs, &$query, &$options, &$ret ) {
                wfProfileIn( __METHOD__ );
 
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
                //NOTE: the model returned by Title::getContentModel() is not 
reliable, see bug 37209
                $model = $target->getContentModel();
-               $entityModels = 
EntityContentFactory::singleton()->getEntityContentModels();
+               $entityModels = $entityContentFactory->getEntityContentModels();
 
 
                // we only want to handle links to Wikibase entities 
differently here
@@ -819,12 +829,14 @@
        public static function onApiCheckCanExecute( \ApiBase $module, User 
$user, &$message ) {
                wfProfileIn( __METHOD__ );
 
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
                if ( $module instanceof \ApiEditPage ) {
                        $params = $module->extractRequestParams();
                        $pageObj = $module->getTitleOrPageId( $params );
                        $namespace = $pageObj->getTitle()->getNamespace();
 
-                       foreach ( 
EntityContentFactory::singleton()->getEntityContentModels() as $model ) {
+                       foreach ( 
$entityContentFactory->getEntityContentModels() as $model ) {
                                /**
                                 * @var EntityHandler $handler
                                 */
@@ -883,9 +895,11 @@
        ) {
                wfProfileIn( __METHOD__ );
 
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+
                $model = $result->getTitle()->getContentModel();
 
-               if ( EntityContentFactory::singleton()->isEntityContentModel( 
$model ) ) {
+               if ( $entityContentFactory->isEntityContentModel( $model ) ) {
                        $lang = $searchPage->getLanguage();
                        $page = WikiPage::factory( $result->getTitle() );
 
diff --git a/repo/includes/ClaimSaver.php b/repo/includes/ClaimSaver.php
index d66ff0e..9541637 100644
--- a/repo/includes/ClaimSaver.php
+++ b/repo/includes/ClaimSaver.php
@@ -138,11 +138,12 @@
         * @throws ExceptionWithCode
         */
        protected function getEntityContent( EntityId $entityId, $revisionId ) {
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                if ( $revisionId === null ) {
-                       $content = 
EntityContentFactory::singleton()->getFromId( $entityId );
+                       $content = $entityContentFactory->getFromId( $entityId 
);
                }
                else {
-                       $content = 
EntityContentFactory::singleton()->getFromRevision( $revisionId );
+                       $content = $entityContentFactory->getFromRevision( 
$revisionId );
                }
 
                if ( $content === null ) {
diff --git a/repo/includes/EditEntity.php b/repo/includes/EditEntity.php
index aa673df..bce7ea0 100644
--- a/repo/includes/EditEntity.php
+++ b/repo/includes/EditEntity.php
@@ -3,6 +3,7 @@
 namespace Wikibase;
 
 use Status, Revision, User, WikiPage, Title, WebRequest, OutputPage;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Handler for editing activity, providing a unified interface for saving 
modified entities while performing
@@ -512,7 +513,7 @@
                }
 
                // create a new entity and tuck it away
-               $this->newContent = 
EntityContentFactory::singleton()->newFromEntity( $patchedCurrent );
+               $this->newContent = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->newFromEntity( 
$patchedCurrent );
 
                return true;
        }
diff --git a/repo/includes/LinkedData/EntityDataRequestHandler.php 
b/repo/includes/LinkedData/EntityDataRequestHandler.php
index 4e20550..5a4ffa9 100644
--- a/repo/includes/LinkedData/EntityDataRequestHandler.php
+++ b/repo/includes/LinkedData/EntityDataRequestHandler.php
@@ -16,6 +16,7 @@
 use \OutputPage;
 use \HttpError;
 use \SquidUpdate;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Request handler implementing a linked data interface for Wikibase entities.
@@ -363,7 +364,7 @@
                                wfDebugLog( __CLASS__, __FUNCTION__ . ": 
revision $revision does not belong to page "
                                        . $page->getTitle()->getPrefixedDBkey() 
);
                                $entity = null;
-                       } elseif ( 
!EntityContentFactory::singleton()->isEntityContentModel( 
$rev->getContentModel() ) ) {
+                       } elseif ( 
!WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->isEntityContentModel(
 $rev->getContentModel() ) ) {
                                wfDebugLog( __CLASS__, __FUNCTION__ . ": 
revision has bad model: "
                                        . $rev->getContentModel() );
                                $entity = null;
diff --git a/repo/includes/Summary.php b/repo/includes/Summary.php
index 4d665c2..b54923f 100644
--- a/repo/includes/Summary.php
+++ b/repo/includes/Summary.php
@@ -356,7 +356,7 @@
                                $string = $arg;
                                break;
                        case is_object( $arg ) && ($arg instanceof EntityId):
-                               $title = 
\Wikibase\EntityContentFactory::singleton()->getTitleForId( $arg );
+                               $title = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getTitleForId( 
$arg );
                                $string = '[[' . $title->getFullText() . ']]';
                                break;
                        case is_object( $arg ) && ( $arg instanceof StringValue 
):
diff --git a/repo/includes/actions/ViewEntityAction.php 
b/repo/includes/actions/ViewEntityAction.php
index d823755..372081b 100644
--- a/repo/includes/actions/ViewEntityAction.php
+++ b/repo/includes/actions/ViewEntityAction.php
@@ -158,7 +158,7 @@
                        $valueFormatters = new ValueFormatterFactory( 
$GLOBALS['wgValueFormatters'] );
                        $dataTypeLookup = 
WikibaseRepo::getDefaultInstance()->getPropertyDataTypeLookup();
                        $entityLoader = 
WikibaseRepo::getDefaultInstance()->getStore()->getEntityRevisionLookup();
-                       $entityTitleLookup = EntityContentFactory::singleton();
+                       $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
 
                        $isEditableView = $this->isPlainView();
 
@@ -167,7 +167,7 @@
                                $valueFormatters,
                                $dataTypeLookup,
                                $entityLoader,
-                               $entityTitleLookup
+                               $entityContentFactory
                        );
 
                        $view->registerJsConfigVars(
diff --git a/repo/includes/api/ClaimModificationHelper.php 
b/repo/includes/api/ClaimModificationHelper.php
index c75bfa4..7b5d9d4 100644
--- a/repo/includes/api/ClaimModificationHelper.php
+++ b/repo/includes/api/ClaimModificationHelper.php
@@ -10,6 +10,7 @@
 use Wikibase\EntityContent;
 use Wikibase\Claim;
 use Wikibase\Claims;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\Summary;
 use Wikibase\Lib\Serializers\SerializerFactory;
 use Wikibase\Entity;
@@ -128,7 +129,7 @@
         * TODO: this could go into a ApiWikibaseHelper as it is useful for 
almost all API modules
         */
        public function getEntityTitle( EntityId $entityId ) {
-               $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
+               $entityTitle = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getTitleForId( 
$entityId );
 
                if ( $entityTitle === null ) {
                        $this->apiMain->dieUsage( 'No such entity' , 
'no-such-entity' );
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index e00c3d8..68a73e0 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -109,7 +109,7 @@
         * @return Entity
         */
        protected function getEntity( EntityId $id ) {
-               $content = EntityContentFactory::singleton()->getFromId( $id );
+               $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( $id );
 
                if ( $content === null ) {
                        $this->dieUsage( 'The specified entity does not exist, 
so it\'s claims cannot be obtained', 'no-such-entity' );
diff --git a/repo/includes/api/GetEntities.php 
b/repo/includes/api/GetEntities.php
index bbec334..76fca4e 100644
--- a/repo/includes/api/GetEntities.php
+++ b/repo/includes/api/GetEntities.php
@@ -176,7 +176,7 @@
        protected function handleEntity( $id, array $params ) {
                wfProfileIn( __METHOD__ );
 
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                $entityIdFormatter = 
WikibaseRepo::getDefaultInstance()->getEntityIdFormatter();
                $entityIdParser = 
WikibaseRepo::getDefaultInstance()->getEntityIdParser();
 
diff --git a/repo/includes/api/SearchEntities.php 
b/repo/includes/api/SearchEntities.php
index f5f8764..209c257 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -4,6 +4,7 @@
 
 use ApiBase;
 use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\StoreFactory;
 use Wikibase\EntityContentFactory;
 use Wikibase\EntityFactory;
@@ -94,8 +95,9 @@
                $ids = array();
                // Gets exact match for the search term as an id if it can be 
found
                $entityId = \Wikibase\EntityId::newFromPrefixedId( 
$params['search'] );
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                if ( $entityId ) {
-                       $page = 
EntityContentFactory::singleton()->getWikiPageForId( $entityId );
+                       $page = $entityContentFactory->getWikiPageForId( 
$entityId );
                        if ( $page->exists() ) {
                                $entityContent = $page->getContent();
                                if ( ( $entityContent instanceof 
\Wikibase\EntityContent ) && ( $entityContent->getEntity()->getType() === 
$params['type'] ) ) {
@@ -131,7 +133,7 @@
                        $entry = array();
 
                        $entry['id'] = $id->getPrefixedId();
-                       $entry['url'] = 
EntityContentFactory::singleton()->getTitleForId( $id )->getFullUrl();
+                       $entry['url'] = $entityContentFactory->getTitleForId( 
$id )->getFullUrl();
 
                        $aliases = array();
                        foreach ( $terms as $term ) {
diff --git a/repo/includes/content/EntityContent.php 
b/repo/includes/content/EntityContent.php
index 058c9f9..42865e7 100644
--- a/repo/includes/content/EntityContent.php
+++ b/repo/includes/content/EntityContent.php
@@ -65,7 +65,7 @@
        public function getWikiPage() {
                if ( $this->wikiPage === false ) {
                        if ( !$this->isNew() ) {
-                               $this->wikiPage = 
EntityContentFactory::singleton()->getWikiPageForId(
+                               $this->wikiPage = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getWikiPageForId(
                                        $this->getEntity()->getId()
                                );
                        }
@@ -124,9 +124,15 @@
                $valueFormatters = new ValueFormatterFactory( 
$GLOBALS['wgValueFormatters'] );
                $dataTypeLookup = 
WikibaseRepo::getDefaultInstance()->getPropertyDataTypeLookup();
                $entityLoader = 
WikibaseRepo::getDefaultInstance()->getStore()->getEntityRevisionLookup();
-               $entityTitleLookup = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
 
-               $entityView = EntityView::newForEntityType( 
$this->getEntity()->getType(), $valueFormatters, $dataTypeLookup, 
$entityLoader, $entityTitleLookup );
+               $entityView = EntityView::newForEntityType(
+                       $this->getEntity()->getType(),
+                       $valueFormatters,
+                       $dataTypeLookup,
+                       $entityLoader,
+                       $entityContentFactory
+               );
                return $entityView->getParserOutput( 
$this->getEntityRevision(), $options, $generateHtml );
        }
 
diff --git a/repo/includes/content/ItemContent.php 
b/repo/includes/content/ItemContent.php
index 6327797..5a566f0 100644
--- a/repo/includes/content/ItemContent.php
+++ b/repo/includes/content/ItemContent.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase;
 use Title, WikiPage, User, MWException, Content, Status, ParserOptions, 
ParserOutput, DataUpdate;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Content object for articles representing Wikibase items.
@@ -170,7 +171,7 @@
                /**
                 * @var WikiPage $ipsPage
                 */
-               $conflictingPage = 
EntityContentFactory::singleton()->getWikiPageForId( $id );
+               $conflictingPage = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getWikiPageForId(
 $id );
 
                $siteSqlStore = \SiteSQLStore::newInstance();
                $site = $siteSqlStore->getSite( $conflict['siteId'] );
diff --git a/repo/includes/content/ItemHandler.php 
b/repo/includes/content/ItemHandler.php
index 83b7334..6416677 100644
--- a/repo/includes/content/ItemHandler.php
+++ b/repo/includes/content/ItemHandler.php
@@ -1,7 +1,9 @@
 <?php
 
 namespace Wikibase;
+
 use User, Title, WikiPage, RequestContext;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Content handler for Wikibase items.
@@ -93,7 +95,7 @@
         */
        public function getContentFromSiteLink( $siteId, $pageName ) {
                $id = $this->getIdForSiteLink( $siteId, $pageName );
-               return $id === false ? null : 
EntityContentFactory::singleton()->getFromId( new EntityId( Item::ENTITY_TYPE, 
$id ) );
+               return $id === false ? null : 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( new 
EntityId( Item::ENTITY_TYPE, $id ) );
        }
 
        /**
@@ -123,7 +125,7 @@
         */
        public function getFromSiteLink( $siteId, $pageName ) {
                $id = $this->getIdForSiteLink( $siteId, $pageName );
-               return $id === false ? null : 
EntityContentFactory::singleton()->getFromId( new EntityId( Item::ENTITY_TYPE, 
$id ) );
+               return $id === false ? null : 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( new 
EntityId( Item::ENTITY_TYPE, $id ) );
        }
 
        /**
@@ -145,7 +147,7 @@
                }
 
                $eid = new EntityId( Item::ENTITY_TYPE, $id );
-               return EntityContentFactory::singleton()->getTitleForId( $eid );
+               return 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getTitleForId( 
$eid );
        }
 
        /**
diff --git a/repo/includes/specials/SpecialEntityData.php 
b/repo/includes/specials/SpecialEntityData.php
index 9ff8100..9645c34 100644
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -52,7 +52,7 @@
                // TODO: use reverse DI facility (global registry/factory)
                $repo = WikibaseRepo::getDefaultInstance();
 
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = $repo->getEntityContentFactory();
                $entityIdParser = $repo->getEntityIdParser();
                $entityIdFormatter = $repo->getIdFormatter();
 
diff --git a/repo/includes/specials/SpecialItemDisambiguation.php 
b/repo/includes/specials/SpecialItemDisambiguation.php
index 805b022..c7c18f9 100644
--- a/repo/includes/specials/SpecialItemDisambiguation.php
+++ b/repo/includes/specials/SpecialItemDisambiguation.php
@@ -7,6 +7,7 @@
 use Wikibase\EntityContentFactory;
 use Wikibase\Item;
 use Wikibase\ItemDisambiguation;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Enables accessing items by providing the label of the item and the language 
of the label.
@@ -62,7 +63,13 @@
                // Display the result set
                if ( isset( $language ) && isset( $label ) ) {
                        // TODO: should search over aliases as well, not just 
labels
-                       $itemContents = 
EntityContentFactory::singleton()->getFromLabel( $language, $label, null, 
Item::ENTITY_TYPE, true );
+                       $itemContents = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromLabel(
+                               $language,
+                               $label,
+                               null,
+                               Item::ENTITY_TYPE,
+                               true
+                       );
 
                        if ( 0 < count( $itemContents ) ) {
                                $this->getOutput()->setPageTitle( $this->msg( 
'wikibase-disambiguation-title', $label )->escaped() );
diff --git a/repo/includes/specials/SpecialModifyEntity.php 
b/repo/includes/specials/SpecialModifyEntity.php
index 53db656..170d39d 100644
--- a/repo/includes/specials/SpecialModifyEntity.php
+++ b/repo/includes/specials/SpecialModifyEntity.php
@@ -8,6 +8,7 @@
 use Wikibase\EntityContentFactory;
 use Wikibase\EntityId;
 use Wikibase\Lib\Specials\SpecialWikibasePage;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\Summary;
 
 /**
@@ -109,7 +110,7 @@
                        $this->entityContent = null;
                }
                else {
-                       $this->entityContent = 
EntityContentFactory::singleton()->getFromId( $id );
+                       $this->entityContent = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( $id );
                }
 
                if ( $rawId === '' ) {
diff --git a/repo/includes/store/sql/SqlStore.php 
b/repo/includes/store/sql/SqlStore.php
index a221f93..7210a4d 100644
--- a/repo/includes/store/sql/SqlStore.php
+++ b/repo/includes/store/sql/SqlStore.php
@@ -3,6 +3,7 @@
 namespace Wikibase;
 
 use DBQueryError;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Implementation of the store interface using an SQL backend via MediaWiki's
@@ -113,7 +114,7 @@
                $pages = $dbw->select(
                        array( 'page' ),
                        array( 'page_id', 'page_latest' ),
-                       array( 'page_content_model' => 
EntityContentFactory::singleton()->getEntityContentModels() ),
+                       array( 'page_content_model' => 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getEntityContentModels()
 ),
                        __METHOD__,
                        array( 'LIMIT' => 1000 ) // TODO: continuation
                );
diff --git a/repo/maintenance/rebuildEntityPerPage.php 
b/repo/maintenance/rebuildEntityPerPage.php
index 97beaa6..40f993a 100644
--- a/repo/maintenance/rebuildEntityPerPage.php
+++ b/repo/maintenance/rebuildEntityPerPage.php
@@ -67,9 +67,7 @@
                );
 
                $entityPerPageTable = StoreFactory::getStore( 'sqlstore' 
)->newEntityPerPage();
-
-               $entityContentFactory = EntityContentFactory::singleton();
-
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                $entityIdParser = 
WikibaseRepo::getDefaultInstance()->getEntityIdParser();
 
                $builder = new EntityPerPageBuilder( $entityPerPageTable, 
$entityContentFactory, $entityIdParser );
diff --git a/repo/maintenance/searchEntityArtefacts.php 
b/repo/maintenance/searchEntityArtefacts.php
index d2bf0ff..096f25c 100644
--- a/repo/maintenance/searchEntityArtefacts.php
+++ b/repo/maintenance/searchEntityArtefacts.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase;
 use Maintenance;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * Script that queries the database for entity artifacts
@@ -64,7 +65,7 @@
        public function searchArtefacts() {
                $dbw = wfGetDB( DB_MASTER );
                $begin = 0;
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                $pageArray = array();
                do {
                        $pages = $dbw->select(
diff --git 
a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
index ee744f9..1d09578 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
@@ -16,6 +16,7 @@
 use Wikibase\LinkedData\EntityDataRequestHandler;
 use Wikibase\LinkedData\EntityDataUriManager;
 use Wikibase\Property;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * @covers \Wikibase\LinkedData\EntityDataRequestHandler
@@ -193,7 +194,7 @@
                        $data = str_replace( '{testitemid}', strtoupper( 
$entity->getId()->getPrefixedId() ), $data );
                        $data = str_replace( '{lowertestitemid}', strtolower( 
$entity->getId()->getPrefixedId() ), $data );
 
-                       $content = 
EntityContentFactory::singleton()->getFromId( $entity->getId() );
+                       $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( 
$entity->getId() );
                        $data = str_replace( '{testitemrev}', 
$content->getWikiPage()->getLatest(), $data );
 
                        $ts = wfTimestamp( TS_RFC2822, 
$content->getWikiPage()->getTimestamp() );
diff --git a/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php 
b/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
index efaad41..1c95f2a 100644
--- a/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
+++ b/repo/tests/phpunit/includes/actions/ViewEntityActionTest.php
@@ -6,6 +6,7 @@
 use Wikibase\Item;
 use Wikibase\EntityId;
 use Wikibase\EntityContentFactory;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\ViewItemAction;
 use WikiPage;
 use Title;
@@ -87,7 +88,7 @@
 
        public function testShow404() {
                $id = new EntityId( Item::ENTITY_TYPE, 1122334455 );
-               $page = EntityContentFactory::singleton()->getWikiPageForId( 
$id );
+               $page = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getWikiPageForId(
 $id );
                $action = $this->createAction( "view", $page );
 
                /* @var \FauxResponse $response */
diff --git a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php 
b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
index 1778b3e..7772301 100644
--- a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
+++ b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
@@ -84,7 +84,7 @@
                while ( $claim = array_shift( $claims ) ) {
                        $this->makeTheRequest( array( $claim->getGuid() ) );
 
-                       $content = 
\Wikibase\EntityContentFactory::singleton()->getFromId( $entity->getId() );
+                       $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( 
$entity->getId() );
                        $obtainedClaims = new \Wikibase\Claims( 
$content->getEntity()->getClaims() );
 
                        $this->assertFalse( $obtainedClaims->hasClaimWithGuid( 
$claim->getGuid() ) );
@@ -112,7 +112,7 @@
 
                $this->makeTheRequest( $guids );
 
-               $content = 
\Wikibase\EntityContentFactory::singleton()->getFromId( $entity->getId() );
+               $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( 
$entity->getId() );
                $obtainedEntity = $content->getEntity();
 
                $this->assertFalse( $obtainedEntity->hasClaims() );
diff --git a/repo/tests/phpunit/includes/api/SetClaimValueTest.php 
b/repo/tests/phpunit/includes/api/SetClaimValueTest.php
index 695f964..d3fc49e 100644
--- a/repo/tests/phpunit/includes/api/SetClaimValueTest.php
+++ b/repo/tests/phpunit/includes/api/SetClaimValueTest.php
@@ -84,7 +84,8 @@
        }
 
        public function doTestValidRequest( Entity $entity, $claimGuid, $value 
) {
-               $content = 
\Wikibase\EntityContentFactory::singleton()->getFromId( $entity->getId() );
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
+               $content = $entityContentFactory->getFromId( $entity->getId() );
                $claimCount = count( $content->getEntity()->getClaims() );
 
                $params = array(
@@ -104,7 +105,7 @@
 
                $this->assertEquals( $value, 
$claim['mainsnak']['datavalue']['value'] );
 
-               $content = 
\Wikibase\EntityContentFactory::singleton()->getFromId( $entity->getId() );
+               $content = $entityContentFactory->getFromId( $entity->getId() );
                $obtainedEntity = $content->getEntity();
 
                $claims = new \Wikibase\Claims( $obtainedEntity->getClaims() );
diff --git a/repo/tests/phpunit/includes/api/SetQualifierTest.php 
b/repo/tests/phpunit/includes/api/SetQualifierTest.php
index fc25146..56b67df 100644
--- a/repo/tests/phpunit/includes/api/SetQualifierTest.php
+++ b/repo/tests/phpunit/includes/api/SetQualifierTest.php
@@ -187,7 +187,7 @@
 
                $this->makeValidRequest( $params );
 
-               $content = 
\Wikibase\EntityContentFactory::singleton()->getFromId( $entityId );
+               $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( 
$entityId );
 
                $this->assertInstanceOf( '\Wikibase\EntityContent', $content );
 
diff --git a/repo/tests/phpunit/includes/api/SetStatementRankTest.php 
b/repo/tests/phpunit/includes/api/SetStatementRankTest.php
index 1a47120..1593b7c 100644
--- a/repo/tests/phpunit/includes/api/SetStatementRankTest.php
+++ b/repo/tests/phpunit/includes/api/SetStatementRankTest.php
@@ -10,6 +10,7 @@
 use Wikibase\PropertySomeValueSnak;
 use Wikibase\PropertyValueSnak;
 use Wikibase\Reference;
+use Wikibase\Repo\WikibaseRepo;
 use Wikibase\Snak;
 use Wikibase\SnakList;
 use Wikibase\Statement;
@@ -147,7 +148,7 @@
 
                $this->assertEquals( $statementRank, $statement['rank'] );
 
-               $itemContent = 
\Wikibase\EntityContentFactory::singleton()->getFromId( $item->getId() );
+               $itemContent = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->getFromId( 
$item->getId() );
 
                $this->assertInstanceOf( '\Wikibase\ItemContent', $itemContent 
);
 
diff --git a/repo/tests/phpunit/includes/content/EntityContentFactoryTest.php 
b/repo/tests/phpunit/includes/content/EntityContentFactoryTest.php
index b203809..a4bbe59 100644
--- a/repo/tests/phpunit/includes/content/EntityContentFactoryTest.php
+++ b/repo/tests/phpunit/includes/content/EntityContentFactoryTest.php
@@ -2,10 +2,12 @@
 
 namespace Wikibase\Test;
 
+use InvalidArgumentException;
 use Wikibase\EntityContentFactory;
 use Wikibase\EntityId;
 use Wikibase\Item;
 use Wikibase\Property;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  * @covers Wikibase\EntityContentFactory
@@ -133,7 +135,7 @@
         * @dataProvider entityTypesProvider
         */
        public function testNewFromType( $type ) {
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                $entityContent = $entityContentFactory->newFromType( $type );
                $this->assertEquals( $type, 
$entityContent->getEntity()->getType() );
        }
@@ -143,7 +145,7 @@
         * @expectedException InvalidArgumentException
         */
        public function testInvalidNewFromType( $type ) {
-               $entityContentFactory = EntityContentFactory::singleton();
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                $entityContent = $entityContentFactory->newFromType( $type );
        }
 
diff --git a/repo/tests/phpunit/includes/content/EntityHandlerTest.php 
b/repo/tests/phpunit/includes/content/EntityHandlerTest.php
index b2082a1..3bf1419 100644
--- a/repo/tests/phpunit/includes/content/EntityHandlerTest.php
+++ b/repo/tests/phpunit/includes/content/EntityHandlerTest.php
@@ -8,6 +8,7 @@
 use Wikibase\EntityFactory;
 use Wikibase\EntityHandler;
 use Wikibase\EntityContent;
+use Wikibase\Repo\WikibaseRepo;
 
 /**
  *  Tests for the Wikibase\EntityHandler class.
@@ -195,7 +196,7 @@
        }
 
        protected function fakeRevision( Entity $entity, $id = 0 ) {
-               $content = EntityContentFactory::singleton()->newFromEntity( 
$entity );
+               $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->newFromEntity( 
$entity );
 
                $revision = new Revision( array(
                        'id' => $id,
diff --git a/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php 
b/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
index 1e28c22..0c07388 100644
--- a/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
+++ b/repo/tests/phpunit/includes/store/sql/EntityPerPageTableTest.php
@@ -54,7 +54,7 @@
                                $entity->setDataTypeId( 'string' );
                        }
 
-                       $content = 
EntityContentFactory::singleton()->newFromEntity( $entity );
+                       $content = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory()->newFromEntity( 
$entity );
                        $title = $content->getTitle();
 
                        if ( !$title->exists() ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f0a0144e1d3187474814dfbf8b5833057dac88d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to