filebackend: optimize 'delete' for FSFileBackend to avoid is_file() calls
[lhc/web/wiklou.git] / includes / cache / LinkBatch.php
index 38cb6be..3edfe1b 100644 (file)
@@ -22,7 +22,7 @@
  */
 use MediaWiki\Linker\LinkTarget;
 use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
 
 /**
@@ -43,7 +43,7 @@ class LinkBatch {
        protected $caller;
 
        /**
-        * @param LinkTarget[] $arr Initial items to be added to the batch
+        * @param Traversable|LinkTarget[] $arr Initial items to be added to the batch
         */
        public function __construct( $arr = [] ) {
                foreach ( $arr as $item ) {
@@ -57,9 +57,12 @@ class LinkBatch {
         * @since 1.17
         *
         * @param string $caller
+        * @return self (since 1.32)
         */
        public function setCaller( $caller ) {
                $this->caller = $caller;
+
+               return $this;
        }
 
        /**
@@ -143,13 +146,13 @@ class LinkBatch {
        }
 
        /**
-        * Add a ResultWrapper containing IDs and titles to a LinkCache object.
+        * Add a result wrapper containing IDs and titles to a LinkCache object.
         * As normal, titles will go into the static Title cache field.
         * This function *also* stores extra fields of the title used for link
         * parsing to avoid extra DB queries.
         *
         * @param LinkCache $cache
-        * @param ResultWrapper $res
+        * @param IResultWrapper $res
         * @return array Array of remaining titles
         */
        public function addResultToCache( $cache, $res ) {
@@ -184,8 +187,8 @@ class LinkBatch {
        }
 
        /**
-        * Perform the existence test query, return a ResultWrapper with page_id fields
-        * @return bool|ResultWrapper
+        * Perform the existence test query, return a result wrapper with page_id fields
+        * @return bool|IResultWrapper
         */
        public function doQuery() {
                if ( $this->isEmpty() ) {
@@ -221,13 +224,13 @@ class LinkBatch {
                if ( $this->isEmpty() ) {
                        return false;
                }
+               $services = MediaWikiServices::getInstance();
 
-               global $wgContLang;
-               if ( !$wgContLang->needsGenderDistinction() ) {
+               if ( !$services->getContentLanguage()->needsGenderDistinction() ) {
                        return false;
                }
 
-               $genderCache = MediaWikiServices::getInstance()->getGenderCache();
+               $genderCache = $services->getGenderCache();
                $genderCache->doLinkBatch( $this->data, $this->caller );
 
                return true;