Defer execution of HTMLCacheUpdate instances
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 6 Oct 2015 20:31:31 +0000 (13:31 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 6 Oct 2015 20:31:31 +0000 (13:31 -0700)
None of these places need it to happen right now,
so for performance and consistent style, defer
them too.

Change-Id: Id0a2a352bfc04a783c3ebc54b059b241bb6a6f7e

includes/Title.php
includes/filerepo/file/File.php
includes/page/WikiFilePage.php
includes/page/WikiPage.php

index e2cbc8e..8e5fae9 100644 (file)
@@ -4418,12 +4418,9 @@ class Title {
         * on the number of links. Typically called on create and delete.
         */
        public function touchLinks() {
-               $u = new HTMLCacheUpdate( $this, 'pagelinks' );
-               $u->doUpdate();
-
+               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks' ) );
                if ( $this->getNamespace() == NS_CATEGORY ) {
-                       $u = new HTMLCacheUpdate( $this, 'categorylinks' );
-                       $u->doUpdate();
+                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'categorylinks' ) );
                }
        }
 
index 43d1eb5..588ae6b 100644 (file)
@@ -1430,8 +1430,7 @@ abstract class File implements IDBAccessObject {
                // Purge cache of all pages using this file
                $title = $this->getTitle();
                if ( $title ) {
-                       $update = new HTMLCacheUpdate( $title, 'imagelinks' );
-                       $update->doUpdate();
+                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
                }
        }
 
index bfcd4c3..c508abe 100644 (file)
@@ -169,8 +169,7 @@ class WikiFilePage extends WikiPage {
                $this->loadFile();
                if ( $this->mFile->exists() ) {
                        wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" );
-                       $update = new HTMLCacheUpdate( $this->mTitle, 'imagelinks' );
-                       $update->doUpdate();
+                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) );
                        $this->mFile->upgradeRow();
                        $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) );
                } else {
index 98cc80a..e47e06c 100644 (file)
@@ -3221,8 +3221,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Images
                if ( $title->getNamespace() == NS_FILE ) {
-                       $update = new HTMLCacheUpdate( $title, 'imagelinks' );
-                       $update->doUpdate();
+                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
                }
 
                // User talk pages