From: daniel Date: Thu, 5 Apr 2012 15:35:15 +0000 (+0200) Subject: use ParserOutput::getLinksUpdateAndOtherUpdates() in order to get all necessary updat... X-Git-Tag: 1.31.0-rc.0~22097^2^2~258 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=commitdiff_plain;h=e67a39f37f4153d1a7f81089752514df2b460f34;p=lhc%2Fweb%2Fwiklou.git use ParserOutput::getLinksUpdateAndOtherUpdates() in order to get all necessary update objects Change-Id: I69c50e0bd59371a6a34b04d2762a882c6e7e60cb --- diff --git a/includes/SecondaryDataUpdate.php b/includes/SecondaryDataUpdate.php index 6527c2d4e9..eeee42f884 100644 --- a/includes/SecondaryDataUpdate.php +++ b/includes/SecondaryDataUpdate.php @@ -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(); + } + } + } diff --git a/includes/WikiPage.php b/includes/WikiPage.php index f91f758d52..174b96e9f8 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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(); } diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index c43c03277e..77898cf72d 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -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'] = ''; diff --git a/includes/job/RefreshLinksJob.php b/includes/job/RefreshLinksJob.php index 1aa206f04a..dcc5ab107c 100644 --- a/includes/job/RefreshLinksJob.php +++ b/includes/job/RefreshLinksJob.php @@ -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(); } diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index c16b6963be..d4d803d5e5 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -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(); } /**