Fix r53270: drop &returntoquery parameter if empty, and prevent Special:Userlogin...
[lhc/web/wiklou.git] / includes / LinksUpdate.php
index 6088fcc..caacb49 100644 (file)
@@ -67,6 +67,7 @@ class LinksUpdate {
                }
 
                $this->mRecursive = $recursive;
+               $this->mTouchTmplLinks = false;
 
                wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
        }
@@ -74,7 +75,7 @@ class LinksUpdate {
        /**
         * Update link tables with outgoing links from an updated article
         */
-       function doUpdate() {
+       public function doUpdate() {
                global $wgUseDumbLinkUpdate;
 
                wfRunHooks( 'LinksUpdate', array( &$this ) );
@@ -84,7 +85,6 @@ class LinksUpdate {
                        $this->doIncrementalUpdate();
                }
                wfRunHooks( 'LinksUpdateComplete', array( &$this ) );
-
        }
 
        protected function doIncrementalUpdate() {
@@ -196,45 +196,21 @@ class LinksUpdate {
                global $wgUpdateRowsPerJob;
                wfProfileIn( __METHOD__ );
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select( 'templatelinks',
-                       array( 'tl_from' ),
-                       array( 
-                               'tl_namespace' => $this->mTitle->getNamespace(),
-                               'tl_title' => $this->mTitle->getDBkey()
-                       ), __METHOD__
-               );
-
-               $numRows = $res->numRows();
-               if( !$numRows ) {
+               $cache = $this->mTitle->getBacklinkCache();
+               $batches = $cache->partition( 'templatelinks', $wgUpdateRowsPerJob );
+               if ( !$batches ) {
                        wfProfileOut( __METHOD__ );
-                       return; // nothing to do
+                       return;
                }
-               $numBatches = ceil( $numRows / $wgUpdateRowsPerJob );
-               $realBatchSize = $numRows / $numBatches;
-               $start = false;
                $jobs = array();
-               do {
-                       for( $i = 0; $i <= $realBatchSize - 1; $i++ ) {
-                               $row = $res->fetchRow();
-                               if( $row ) {
-                                       $id = $row[0];
-                               } else {
-                                       $id = false;
-                                       break;
-                               }
-                       }
+               foreach ( $batches as $batch ) {
+                       list( $start, $end ) = $batch;
                        $params = array(
                                'start' => $start,
-                               'end' => ( $id !== false ? $id - 1 : false ),
+                               'end' => $end,
                        );
                        $jobs[] = new RefreshLinksJob2( $this->mTitle, $params );
-
-                       $start = $id;
-               } while ( $start );
-
-               $dbr->freeResult( $res );
-
+               }
                Job::batchInsert( $jobs );
 
                wfProfileOut( __METHOD__ );
@@ -302,7 +278,7 @@ class LinksUpdate {
        }
 
        function invalidateImageDescriptions( $images ) {
-               $this->invalidatePages( NS_IMAGE, array_keys( $images ) );
+               $this->invalidatePages( NS_FILE, array_keys( $images ) );
        }
 
        function dumbTableUpdate( $table, $insertions, $fromField ) {
@@ -450,9 +426,12 @@ class LinksUpdate {
         * @private
         */
        function getCategoryInsertions( $existing = array() ) {
+               global $wgContLang;
                $diffs = array_diff_assoc( $this->mCategories, $existing );
                $arr = array();
                foreach ( $diffs as $name => $sortkey ) {
+                       $nt = Title::makeTitleSafe( NS_CATEGORY, $name );
+                       $wgContLang->findVariantLink( $name, $nt, true );
                        $arr[] = array(
                                'cl_from'    => $this->mId,
                                'cl_to'      => $name,