use ParserOutput::getLinksUpdateAndOtherUpdates() in order to get all necessary updat...
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 5 Apr 2012 15:35:15 +0000 (17:35 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 5 Apr 2012 15:35:15 +0000 (17:35 +0200)
Change-Id: I69c50e0bd59371a6a34b04d2762a882c6e7e60cb

includes/SecondaryDataUpdate.php
includes/WikiPage.php
includes/api/ApiPurge.php
includes/job/RefreshLinksJob.php
maintenance/refreshLinks.php

index 6527c2d..eeee42f 100644 (file)
@@ -26,11 +26,26 @@ abstract class SecondaryDataUpdate {
         * Constructor
         */
     public function __construct( ) {
+        # noop
        }
 
        /**
-        * Update link tables with outgoing links from an updated article
+        * Perform update.
         */
        public abstract function doUpdate();
 
+    /**
+     * Conveniance method, calls doUpdate() on every element in the array.
+     *
+     * @static
+     * @param $updates array
+     */
+    public static function runUpdates( $updates ) {
+        if ( empty( $updates ) ) return; # nothing to do
+
+        foreach ( $updates as $update ) {
+            $update->doUpdate();
+        }
+    }
+
 }
index f91f758..174b96e 100644 (file)
@@ -1702,9 +1702,9 @@ class WikiPage extends Page {
                        $parserCache->save( $editInfo->output, $this, $editInfo->popts );
                }
 
-               # Update the links tables
-               $u = new LinksUpdate( $this->mTitle, $editInfo->output );
-               $u->doUpdate();
+               # Update the links tables and other secondary data
+        $updates = $editInfo->output->getLinksUpdateAndOtherUpdates( $this->mTitle );
+        SecondaryDataUpdate::runUpdates( $updates );
 
                wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );
 
@@ -2691,6 +2691,7 @@ class WikiPage extends Page {
 
                if ( count( $templates_diff ) > 0 ) {
                        # Whee, link updates time.
+            # Note: we are only interested in links here. We don't need to get other SecondaryDataUpdate items from the parser output.
                        $u = new LinksUpdate( $this->mTitle, $parserOutput, false );
                        $u->doUpdate();
                }
index c43c032..77898cf 100644 (file)
@@ -93,8 +93,8 @@ class ApiPurge extends ApiBase {
                                                true, true, $page->getLatest() ); #FIXME: content!
 
                                        # Update the links tables
-                                       $u = new LinksUpdate( $title, $p_result );
-                                       $u->doUpdate();
+                    $updates = $p_result->getLinksUpdateAndOtherUpdates( $title );
+                    SecondaryDataUpdate::runUpdates( $updates );
 
                                        $r['linkupdate'] = '';
 
index 1aa206f..dcc5ab1 100644 (file)
@@ -46,9 +46,11 @@ class RefreshLinksJob extends Job {
                $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
                wfProfileOut( __METHOD__.'-parse' );
                wfProfileIn( __METHOD__.'-update' );
-               $update = new LinksUpdate( $this->title, $parserOutput, false );
-               $update->doUpdate();
-               wfProfileOut( __METHOD__.'-update' );
+
+        $updates = $parserOutput->getLinksUpdateAndOtherUpdates( $this->title, false );
+        SecondaryDataUpdate::runUpdates( $updates );
+
+        wfProfileOut( __METHOD__.'-update' );
                wfProfileOut( __METHOD__ );
                return true;
        }
@@ -118,8 +120,10 @@ class RefreshLinksJob2 extends Job {
                        $parserOutput = $wgParser->parse( $revision->getText(), $title, $options, true, true, $revision->getId() );
                        wfProfileOut( __METHOD__.'-parse' );
                        wfProfileIn( __METHOD__.'-update' );
-                       $update = new LinksUpdate( $title, $parserOutput, false );
-                       $update->doUpdate();
+
+            $updates = $parserOutput->getLinksUpdateAndOtherUpdates( $title, false );
+            SecondaryDataUpdate::runUpdates( $updates );
+
                        wfProfileOut( __METHOD__.'-update' );
                        wfWaitForSlaves();
                }
index c16b696..d4d803d 100644 (file)
@@ -221,9 +221,11 @@ class RefreshLinks extends Maintenance {
 
                $options = new ParserOptions;
                $parserOutput = $wgParser->parse( $revision->getText(), $title, $options, true, true, $revision->getId() );
-               $update = new LinksUpdate( $title, $parserOutput, false );
-               $update->doUpdate();
-               $dbw->commit();
+
+        $updates = $parserOutput->getLinksUpdateAndOtherUpdates( $title, false );
+        SecondaryDataUpdate::runUpdates( $updates );
+
+        $dbw->commit();
        }
 
        /**