cleanup and fixes for secondary data updates
[lhc/web/wiklou.git] / includes / job / RefreshLinksJob.php
index cc91fa8..fa3a607 100644 (file)
@@ -2,6 +2,21 @@
 /**
  * Job to update links for a given title.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup JobQueue
  */
@@ -22,7 +37,7 @@ class RefreshLinksJob extends Job {
         * @return boolean success
         */
        function run() {
-               global $wgParser;
+               global $wgParser, $wgContLang;
                wfProfileIn( __METHOD__ );
 
                $linkCache = LinkCache::singleton();
@@ -42,12 +57,14 @@ class RefreshLinksJob extends Job {
                }
 
                wfProfileIn( __METHOD__.'-parse' );
-               $options = new ParserOptions;
-               $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
+               $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
+               $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() ); #FIXME: content
                wfProfileOut( __METHOD__.'-parse' );
                wfProfileIn( __METHOD__.'-update' );
-               $update = new LinksUpdate( $this->title, $parserOutput, false );
-               $update->doUpdate();
+
+               $updates = $parserOutput->getSecondaryDataUpdates( $this->title, false ); #FIXME: content handler
+               DataUpdate::runUpdates( $updates );
+
                wfProfileOut( __METHOD__.'-update' );
                wfProfileOut( __METHOD__ );
                return true;
@@ -71,7 +88,7 @@ class RefreshLinksJob2 extends Job {
         * @return boolean success
         */
        function run() {
-               global $wgParser;
+               global $wgParser, $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
@@ -88,8 +105,10 @@ class RefreshLinksJob2 extends Job {
                        wfProfileOut( __METHOD__ );
                        return false;
                }
+               // Back compat for pre-r94435 jobs
+               $table = isset( $this->params['table'] ) ? $this->params['table'] : 'templatelinks';
                $titles = $this->title->getBacklinkCache()->getLinks( 
-                       'templatelinks', $this->params['start'], $this->params['end']);
+                       $table, $this->params['start'], $this->params['end']);
                
                # Not suitable for page load triggered job running!
                # Gracefully switch to refreshLinks jobs if this happens.
@@ -103,6 +122,7 @@ class RefreshLinksJob2 extends Job {
                        wfProfileOut( __METHOD__ );
                        return true;
                }
+               $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
                # Re-parse each page that transcludes this page and update their tracking links...
                foreach ( $titles as $title ) {
                        $revision = Revision::newFromTitle( $title );
@@ -112,14 +132,15 @@ class RefreshLinksJob2 extends Job {
                                return false;
                        }
                        wfProfileIn( __METHOD__.'-parse' );
-                       $options = new ParserOptions;
-                       $parserOutput = $wgParser->parse( $revision->getText(), $title, $options, true, true, $revision->getId() );
+                       $parserOutput = $wgParser->parse( $revision->getText(), $title, $options, true, true, $revision->getId() ); #FIXME: content handler
                        wfProfileOut( __METHOD__.'-parse' );
                        wfProfileIn( __METHOD__.'-update' );
-                       $update = new LinksUpdate( $title, $parserOutput, false );
-                       $update->doUpdate();
+
+                       $updates = $parserOutput->getSecondaryDataUpdates( $title, false ); #FIXME: content handler
+                       DataUpdate::runUpdates( $updates );
+
                        wfProfileOut( __METHOD__.'-update' );
-                       wfWaitForSlaves( 5 );
+                       wfWaitForSlaves();
                }
                wfProfileOut( __METHOD__ );