From 96b4779ebdd463c13f459c7659981df6b28e2d0e Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 16 May 2012 20:14:14 +0200 Subject: [PATCH] introducing Content::getSecondaryDataUpdates() --- includes/Content.php | 27 ++++++++++++++++++++++++++- includes/WikiPage.php | 3 ++- maintenance/refreshLinks.php | 5 +---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/includes/Content.php b/includes/Content.php index 4fc6e1b749..54024991cf 100644 --- a/includes/Content.php +++ b/includes/Content.php @@ -302,7 +302,32 @@ abstract class Content { * * @return ParserOutput */ - public abstract function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = NULL, $generateHtml = true ); + public abstract function getParserOutput( IContextSource $context, $revId = null, ParserOptions $options = null, $generateHtml = true ); + + /** + * Returns a list of DataUpdate objects for recording information about this Content in some secondary + * data store. If the optional second argument, $old, is given, the updates may model only the changes that + * need to be made to replace information about the old content with infomration about the new content. + * + * This default implementation calls $this->getParserOutput( $context, null, null, false ), and then + * calls getSecondaryDataUpdates( $context->getTitle(), $recursive ) on the resulting ParserOutput object. + * + * Subclasses may implement this to determine the necessary updates more efficiently, or make use of information + * about the old content. + * + * @param IContextSource $context the content for determining the necessary updates + * @param Content|null $old a Content object representing the previous content, i.e. the content being + * replaced by this Content object. + * @param bool $recursive whether to include recursive updates (default: false). + * + * @return Array. A list of DataUpdate objects for putting information about this content object somewhere. + * + * @since WD.1 + */ + public function getSecondaryDataUpdates( IContextSource $context, Content $old = null, $recursive = false ) { + $po = $this->getParserOutput( $context, null, null, false ); + return $po->getSecondaryDataUpdates( $context->getTitle(), $recursive ); + } /** * Construct the redirect destination from this content and return an diff --git a/includes/WikiPage.php b/includes/WikiPage.php index eaf32fe80f..8f73eecab5 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1938,6 +1938,7 @@ class WikiPage extends Page { $context = RequestContext::getMain(); $context->setTitle( $this->mTitle ); $edit->output = $edit->pstContent->getParserOutput( $context, $revid, $edit->popts ); + $edit->updates = $edit->pstContent->getSecondaryDataUpdate( $context ); $edit->newContent = $content; $edit->oldContent = $this->getContent( Revision::RAW ); @@ -1991,7 +1992,7 @@ class WikiPage extends Page { } # Update the links tables and other secondary data - $updates = $editInfo->output->getSecondaryDataUpdates( $this->mTitle ); + $updates = $editInfo->updates; DataUpdate::runUpdates( $updates ); wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) ); diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index 7ff3be64b7..f954b9ef5d 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -218,12 +218,9 @@ class RefreshLinks extends Maintenance { $dbw = wfGetDB( DB_MASTER ); $dbw->begin( __METHOD__ ); - $options = ParserOptions::newFromUserAndLang( new User, $wgContLang ); $context = RequestContext::getMain(); - $parserOutput = $content->getParserOutput( $context, $page->getLatest(), $options, false ); - - $updates = $parserOutput->getSecondaryDataUpdates( $page->getTitle(), false ); + $updates = $content->getSecondaryDataUpdates( $context ); DataUpdate::runUpdates( $updates ); $dbw->commit( __METHOD__ ); -- 2.20.1