From 27980cd92b4af2b0478088742bbf30f2a8a8e540 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 20 Sep 2008 22:48:55 +0000 Subject: [PATCH] * Avoid doing templatelinks query (which can get huge) twice by adding cachupdate jobs using the same query as refreshlinks jobs do * Don't trigger recursive jobs for nulls edits * Some whitespace tweaks --- includes/Article.php | 24 +++++++++++++----------- includes/Import.php | 2 +- includes/LinksUpdate.php | 21 ++++++++++++++++++--- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 9ffc2f2152..78f467a57f 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1539,8 +1539,7 @@ class Article { if ( $good ) { # Invalidate cache of this article and all pages using this article # as a template. Partly deferred. - Article::onArticleEdit( $this->mTitle ); - + Article::onArticleEdit( $this->mTitle, false ); // leave templatelinks for editUpdates() # Update links tables, site stats, etc. $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed ); $dbw->commit(); @@ -1593,7 +1592,7 @@ class Article { Article::onArticleCreate( $this->mTitle ); wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary, - $flags & EDIT_MINOR, null, null, &$flags, $revision ) ); + $flags & EDIT_MINOR, null, null, &$flags, $revision ) ); } if ( $good && !( $flags & EDIT_DEFER_UPDATES ) ) { @@ -2701,6 +2700,7 @@ class Article { /** * Do standard deferred updates after page edit. * Update links tables, site stats, search index and message cache. + * Purges pages that include this page if the text was changed here. * Every 100th edit, prune the recent changes table. * * @private @@ -2733,7 +2733,8 @@ class Article { } # Update the links tables - $u = new LinksUpdate( $this->mTitle, $editInfo->output ); + $u = new LinksUpdate( $this->mTitle, $editInfo->output, false ); + $u->setRecursiveTouch( $changed ); // refresh/invalidate including pages too $u->doUpdate(); if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { @@ -2879,7 +2880,8 @@ class Article { $r = "\n\t\t\t\t
" . wfMsg( $infomsg, $td, $userlinks ) . "
\n" . - "\n\t\t\t\t
" . $cdel . wfMsg( 'revision-nav', $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "
\n\t\t\t"; + "\n\t\t\t\t
" . $cdel . wfMsg( 'revision-nav', $prevdiff, + $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "
\n\t\t\t"; $wgOut->setSubtitle( $r ); } @@ -3101,8 +3103,8 @@ class Article { * @param $title_obj a title object */ - public static function onArticleCreate($title) { - # The talk page isn't in the regular link tables, so we need to update manually: + public static function onArticleCreate( $title ) { + # Update existence markers on article/talk tabs... if ( $title->isTalkPage() ) { $other = $title->getSubjectPage(); } else { @@ -3118,8 +3120,7 @@ class Article { public static function onArticleDelete( $title ) { global $wgUseFileCache, $wgMessageCache; - - // Update existence markers on article/talk tabs... + # Update existence markers on article/talk tabs... if( $title->isTalkPage() ) { $other = $title->getSubjectPage(); } else { @@ -3156,11 +3157,12 @@ class Article { /** * Purge caches on page update etc */ - static function onArticleEdit( $title ) { + public static function onArticleEdit( $title, $touchTemplates = true ) { global $wgDeferredUpdateList, $wgUseFileCache; // Invalidate caches of articles which include this page - $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' ); + if( $touchTemplates ) + $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' ); // Invalidate the caches of all pages which redirect here $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' ); diff --git a/includes/Import.php b/includes/Import.php index a5bd182cf7..b8db93435f 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -219,7 +219,7 @@ class WikiRevision { } elseif( $changed ) { wfDebug( __METHOD__ . ": running onArticleEdit\n" ); - Article::onArticleEdit( $this->title ); + Article::onArticleEdit( $this->title, false ); // leave templatelinks for editUpdates() wfDebug( __METHOD__ . ": running edit updates\n" ); $article->editUpdates( diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 6088fcc9ea..4b8f6d6f1d 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -20,7 +20,8 @@ class LinksUpdate { $mProperties, //!< Map of arbitrary name to value $mDb, //!< Database connection reference $mOptions, //!< SELECT options to be used (array) - $mRecursive; //!< Whether to queue jobs for recursive updates + $mRecursive, //!< Whether to queue jobs for recursive updates + $mTouchTmplLinks; //!< Whether to queue HTMLCacheUpdate jobs IF recursive /**@}}*/ /** @@ -67,14 +68,24 @@ class LinksUpdate { } $this->mRecursive = $recursive; + $this->mTouchTmplLinks = false; wfRunHooks( 'LinksUpdateConstructed', array( &$this ) ); } + + /** + * Invalidate HTML cache of pages that include this page? + */ + public function setRecursiveTouch( $val ) { + $this->mTouchTmplLinks = (bool)$val; + if( $val ) // Cannot invalidate without queueRecursiveJobs() + $this->mRecursive = true; + } /** * Update link tables with outgoing links from an updated article */ - function doUpdate() { + public function doUpdate() { global $wgUseDumbLinkUpdate; wfRunHooks( 'LinksUpdate', array( &$this ) ); @@ -229,7 +240,11 @@ class LinksUpdate { 'end' => ( $id !== false ? $id - 1 : false ), ); $jobs[] = new RefreshLinksJob2( $this->mTitle, $params ); - + # Hit page caches while we're at it if set to do so... + if( $this->mTouchTmplLinks ) { + $params['table'] = 'templatelinks'; + $jobs[] = new HTMLCacheUpdateJob( $this->mTitle, $params ); + } $start = $id; } while ( $start ); -- 2.20.1