Localisation updates from http://translatewiki.net.
[lhc/web/wiklou.git] / includes / LinksUpdate.php
index 87db4d6..7ddf863 100644 (file)
@@ -49,6 +49,7 @@ class LinksUpdate extends SqlDataUpdate {
         * @param $title Title of the page we're updating
         * @param $parserOutput ParserOutput: output from a full parse of this page
         * @param $recursive Boolean: queue jobs for recursive updates?
+        * @throws MWException
         */
        function __construct( $title, $parserOutput, $recursive = true ) {
                parent::__construct( false ); // no implicit transaction
@@ -71,6 +72,7 @@ class LinksUpdate extends SqlDataUpdate {
                }
 
                $this->mParserOutput = $parserOutput;
+
                $this->mLinks = $parserOutput->getLinks();
                $this->mImages = $parserOutput->getImages();
                $this->mTemplates = $parserOutput->getTemplates();
@@ -236,26 +238,20 @@ class LinksUpdate extends SqlDataUpdate {
        }
 
        function queueRecursiveJobs() {
-               global $wgUpdateRowsPerJob;
                wfProfileIn( __METHOD__ );
 
-               $cache = $this->mTitle->getBacklinkCache();
-               $batches = $cache->partition( 'templatelinks', $wgUpdateRowsPerJob );
-               if ( !$batches ) {
-                       wfProfileOut( __METHOD__ );
-                       return;
-               }
-               $jobs = array();
-               foreach ( $batches as $batch ) {
-                       list( $start, $end ) = $batch;
-                       $params = array(
-                               'table' => 'templatelinks',
-                               'start' => $start,
-                               'end' => $end,
+               if ( $this->mTitle->getBacklinkCache()->hasLinks( 'templatelinks' ) ) {
+                       $job = new RefreshLinksJob2(
+                               $this->mTitle,
+                               array(
+                                       'table' => 'templatelinks',
+                               ) + Job::newRootJobParams( // "overall" refresh links job info
+                                       "refreshlinks:templatelinks:{$this->mTitle->getPrefixedText()}"
+                               )
                        );
-                       $jobs[] = new RefreshLinksJob2( $this->mTitle, $params );
+                       JobQueueGroup::singleton()->push( $job );
+                       JobQueueGroup::singleton()->deduplicateRootJob( $job );
                }
-               Job::batchInsert( $jobs );
 
                wfProfileOut( __METHOD__ );
        }
@@ -823,11 +819,16 @@ class LinksDeletionUpdate extends SqlDataUpdate {
         * Constructor
         *
         * @param $page WikiPage Page we are updating
+        * @throws MWException
         */
        function __construct( WikiPage $page ) {
                parent::__construct( false ); // no implicit transaction
 
                $this->mPage = $page;
+
+               if ( !$page->exists() ) {
+                       throw new MWException( "Page ID not known, perhaps the page doesn't exist?" );
+               }
        }
 
        /**
@@ -879,4 +880,16 @@ class LinksDeletionUpdate extends SqlDataUpdate {
                                __METHOD__ );
                }
        }
+
+       /**
+        * Update all the appropriate counts in the category table.
+        * @param $added array associative array of category name => sort key
+        * @param $deleted array associative array of category name => sort key
+        */
+       function updateCategoryCounts( $added, $deleted ) {
+               $a = WikiPage::factory( $this->mTitle );
+               $a->updateCategoryCounts(
+                       array_keys( $added ), array_keys( $deleted )
+               );
+       }
 }