From: Kunal Mehta Date: Mon, 23 May 2016 05:55:38 +0000 (-0700) Subject: LinkBatch: Use TitleValue instead of Title X-Git-Tag: 1.31.0-rc.0~6798 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=682116760198a7420a809e0b9966ecdc63f1c67d;p=lhc%2Fweb%2Fwiklou.git LinkBatch: Use TitleValue instead of Title Replace the remaining instances of Title with TitleValue, and use services from MediaWikiServices instead of calling deprecated singleton functions. Change-Id: I5d13939a76380fff6b787cea8d4a5f90c1a31a5d --- diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php index a7dd5709c2..04d2524d91 100644 --- a/includes/cache/LinkBatch.php +++ b/includes/cache/LinkBatch.php @@ -21,6 +21,7 @@ * @ingroup Cache */ use MediaWiki\Linker\LinkTarget; +use MediaWiki\MediaWikiServices; /** * Class representing a list of titles @@ -116,7 +117,7 @@ class LinkBatch { * @return array Mapping PDBK to ID */ public function execute() { - $linkCache = LinkCache::singleton(); + $linkCache = MediaWikiServices::getInstance()->getLinkCache(); return $this->executeInto( $linkCache ); } @@ -151,23 +152,26 @@ class LinkBatch { return []; } + $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter(); // For each returned entry, add it to the list of good links, and remove it from $remaining $ids = []; $remaining = $this->data; foreach ( $res as $row ) { - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); + $title = new TitleValue( (int)$row->page_namespace, $row->page_title ); $cache->addGoodLinkObjFromRow( $title, $row ); - $ids[$title->getPrefixedDBkey()] = $row->page_id; + $pdbk = $titleFormatter->getPrefixedDBkey( $title ); + $ids[$pdbk] = $row->page_id; unset( $remaining[$row->page_namespace][$row->page_title] ); } // The remaining links in $data are bad links, register them as such foreach ( $remaining as $ns => $dbkeys ) { foreach ( $dbkeys as $dbkey => $unused ) { - $title = Title::makeTitle( $ns, $dbkey ); + $title = new TitleValue( (int)$ns, $dbkey ); $cache->addBadLinkObj( $title ); - $ids[$title->getPrefixedDBkey()] = 0; + $pdbk = $titleFormatter->getPrefixedDBkey( $title ); + $ids[$pdbk] = 0; } } @@ -218,7 +222,7 @@ class LinkBatch { return false; } - $genderCache = GenderCache::singleton(); + $genderCache = MediaWikiServices::getInstance()->getGenderCache(); $genderCache->doLinkBatch( $this->data, $this->caller ); return true;