r41081 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41080‎ | r41081 | r41082 >
Date:22:48, 20 September 2008
Author:aaron
Status:old (Comments)
Tags:
Comment:
* 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
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Import.php (modified) (history)
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1539,8 +1539,7 @@
15401540 if ( $good ) {
15411541 # Invalidate cache of this article and all pages using this article
15421542 # as a template. Partly deferred.
1543 - Article::onArticleEdit( $this->mTitle );
1544 -
 1543+ Article::onArticleEdit( $this->mTitle, false ); // leave templatelinks for editUpdates()
15451544 # Update links tables, site stats, etc.
15461545 $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed );
15471546 $dbw->commit();
@@ -1593,7 +1592,7 @@
15941593 Article::onArticleCreate( $this->mTitle );
15951594
15961595 wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary,
1597 - $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
 1596+ $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
15981597 }
15991598
16001599 if ( $good && !( $flags & EDIT_DEFER_UPDATES ) ) {
@@ -2701,6 +2700,7 @@
27022701 /**
27032702 * Do standard deferred updates after page edit.
27042703 * Update links tables, site stats, search index and message cache.
 2704+ * Purges pages that include this page if the text was changed here.
27052705 * Every 100th edit, prune the recent changes table.
27062706 *
27072707 * @private
@@ -2733,7 +2733,8 @@
27342734 }
27352735
27362736 # Update the links tables
2737 - $u = new LinksUpdate( $this->mTitle, $editInfo->output );
 2737+ $u = new LinksUpdate( $this->mTitle, $editInfo->output, false );
 2738+ $u->setRecursiveTouch( $changed ); // refresh/invalidate including pages too
27382739 $u->doUpdate();
27392740
27402741 if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
@@ -2879,7 +2880,8 @@
28802881
28812882 $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" . wfMsg( $infomsg, $td, $userlinks ) . "</div>\n" .
28822883
2883 - "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsg( 'revision-nav', $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
 2884+ "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsg( 'revision-nav', $prevdiff,
 2885+ $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
28842886 $wgOut->setSubtitle( $r );
28852887 }
28862888
@@ -3101,8 +3103,8 @@
31023104 * @param $title_obj a title object
31033105 */
31043106
3105 - public static function onArticleCreate($title) {
3106 - # The talk page isn't in the regular link tables, so we need to update manually:
 3107+ public static function onArticleCreate( $title ) {
 3108+ # Update existence markers on article/talk tabs...
31073109 if ( $title->isTalkPage() ) {
31083110 $other = $title->getSubjectPage();
31093111 } else {
@@ -3118,8 +3120,7 @@
31193121
31203122 public static function onArticleDelete( $title ) {
31213123 global $wgUseFileCache, $wgMessageCache;
3122 -
3123 - // Update existence markers on article/talk tabs...
 3124+ # Update existence markers on article/talk tabs...
31243125 if( $title->isTalkPage() ) {
31253126 $other = $title->getSubjectPage();
31263127 } else {
@@ -3156,11 +3157,12 @@
31573158 /**
31583159 * Purge caches on page update etc
31593160 */
3160 - static function onArticleEdit( $title ) {
 3161+ public static function onArticleEdit( $title, $touchTemplates = true ) {
31613162 global $wgDeferredUpdateList, $wgUseFileCache;
31623163
31633164 // Invalidate caches of articles which include this page
3164 - $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
 3165+ if( $touchTemplates )
 3166+ $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
31653167
31663168 // Invalidate the caches of all pages which redirect here
31673169 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' );
Index: trunk/phase3/includes/LinksUpdate.php
@@ -20,7 +20,8 @@
2121 $mProperties, //!< Map of arbitrary name to value
2222 $mDb, //!< Database connection reference
2323 $mOptions, //!< SELECT options to be used (array)
24 - $mRecursive; //!< Whether to queue jobs for recursive updates
 24+ $mRecursive, //!< Whether to queue jobs for recursive updates
 25+ $mTouchTmplLinks; //!< Whether to queue HTMLCacheUpdate jobs IF recursive
2526 /**@}}*/
2627
2728 /**
@@ -67,14 +68,24 @@
6869 }
6970
7071 $this->mRecursive = $recursive;
 72+ $this->mTouchTmplLinks = false;
7173
7274 wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
7375 }
 76+
 77+ /**
 78+ * Invalidate HTML cache of pages that include this page?
 79+ */
 80+ public function setRecursiveTouch( $val ) {
 81+ $this->mTouchTmplLinks = (bool)$val;
 82+ if( $val ) // Cannot invalidate without queueRecursiveJobs()
 83+ $this->mRecursive = true;
 84+ }
7485
7586 /**
7687 * Update link tables with outgoing links from an updated article
7788 */
78 - function doUpdate() {
 89+ public function doUpdate() {
7990 global $wgUseDumbLinkUpdate;
8091
8192 wfRunHooks( 'LinksUpdate', array( &$this ) );
@@ -229,7 +240,11 @@
230241 'end' => ( $id !== false ? $id - 1 : false ),
231242 );
232243 $jobs[] = new RefreshLinksJob2( $this->mTitle, $params );
233 -
 244+ # Hit page caches while we're at it if set to do so...
 245+ if( $this->mTouchTmplLinks ) {
 246+ $params['table'] = 'templatelinks';
 247+ $jobs[] = new HTMLCacheUpdateJob( $this->mTitle, $params );
 248+ }
234249 $start = $id;
235250 } while ( $start );
236251
Index: trunk/phase3/includes/Import.php
@@ -219,7 +219,7 @@
220220
221221 } elseif( $changed ) {
222222 wfDebug( __METHOD__ . ": running onArticleEdit\n" );
223 - Article::onArticleEdit( $this->title );
 223+ Article::onArticleEdit( $this->title, false ); // leave templatelinks for editUpdates()
224224
225225 wfDebug( __METHOD__ . ": running edit updates\n" );
226226 $article->editUpdates(

Follow-up revisions

RevisionCommit summaryAuthorDate
r47317* Mostly reverted r41081 and related. Although the motivation (to save a quer...tstarling14:26, 16 February 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   20:30, 17 February 2009

Mostly reverted by r47317

Status & tagging log