Merge "Clean up use of IDatabase::affectedRows() in WikiPage::updateRedirectOn()"
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 1ff9101..8cc5a39 100644 (file)
@@ -1300,8 +1300,13 @@ class WikiPage implements Page, IDBAccessObject {
 
                $this->mTitle->invalidateCache();
 
-               // Clear file cache and send purge after above page_touched update was committed
-               MediaWikiServices::getInstance()->getHtmlCacheUpdater()->purge( $this->mTitle );
+               // Clear file cache
+               HTMLFileCache::clearFileCache( $this->getTitle() );
+               // Send purge after above page_touched update was committed
+               DeferredUpdates::addUpdate(
+                       new CdnCacheUpdate( $this->mTitle->getCdnUrls() ),
+                       DeferredUpdates::PRESEND
+               );
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                        $messageCache = MessageCache::singleton();
@@ -3386,20 +3391,18 @@ class WikiPage implements Page, IDBAccessObject {
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
-               MediaWikiServices::getInstance()->getHtmlCacheUpdater()->purge( [ $title, $other ] );
+               $other->purgeSquid();
 
                $title->touchLinks();
+               $title->purgeSquid();
                $title->deleteTitleProtection();
 
                MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );
 
                // Invalidate caches of articles which include this page
-               $job = HTMLCacheUpdateJob::newForBacklinks(
-                       $title,
-                       'templatelinks',
-                       [ 'causeAction' => 'page-create' ]
+               DeferredUpdates::addUpdate(
+                       new HTMLCacheUpdate( $title, 'templatelinks', 'page-create' )
                );
-               JobQueueGroup::singleton()->lazyPush( $job );
 
                if ( $title->getNamespace() == NS_CATEGORY ) {
                        // Load the Category object, which will schedule a job to create
@@ -3419,14 +3422,19 @@ class WikiPage implements Page, IDBAccessObject {
                // TODO: move this into a PageEventEmitter service
 
                // Update existence markers on article/talk tabs...
+               // Clear Backlink cache first so that purge jobs use more up-to-date backlink information
+               BacklinkCache::get( $title )->clear();
                $other = $title->getOtherPage();
 
-               MediaWikiServices::getInstance()->getHtmlCacheUpdater()->purge( [ $title, $other ] );
+               $other->purgeSquid();
 
                $title->touchLinks();
+               $title->purgeSquid();
 
                MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );
 
+               // File cache
+               HTMLFileCache::clearFileCache( $title );
                InfoAction::invalidateCache( $title );
 
                // Messages
@@ -3436,12 +3444,9 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Images
                if ( $title->getNamespace() == NS_FILE ) {
-                       $job = HTMLCacheUpdateJob::newForBacklinks(
-                               $title,
-                               'imagelinks',
-                               [ 'causeAction' => 'page-delete' ]
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' )
                        );
-                       JobQueueGroup::singleton()->lazyPush( $job );
                }
 
                // User talk pages
@@ -3474,28 +3479,26 @@ class WikiPage implements Page, IDBAccessObject {
        ) {
                // TODO: move this into a PageEventEmitter service
 
-               $jobs = [];
-               if ( $slotsChanged === null || in_array( SlotRecord::MAIN, $slotsChanged ) ) {
+               if ( $slotsChanged === null || in_array( SlotRecord::MAIN,  $slotsChanged ) ) {
                        // Invalidate caches of articles which include this page.
                        // Only for the main slot, because only the main slot is transcluded.
                        // TODO: MCR: not true for TemplateStyles! [SlotHandler]
-                       $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
-                               $title,
-                               'templatelinks',
-                               [ 'causeAction' => 'page-edit' ]
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $title, 'templatelinks', 'page-edit' )
                        );
                }
+
                // Invalidate the caches of all pages which redirect here
-               $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
-                       $title,
-                       'redirect',
-                       [ 'causeAction' => 'page-edit' ]
+               DeferredUpdates::addUpdate(
+                       new HTMLCacheUpdate( $title, 'redirect', 'page-edit' )
                );
-               JobQueueGroup::singleton()->lazyPush( $jobs );
 
                MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );
 
-               MediaWikiServices::getInstance()->getHtmlCacheUpdater()->purge( $title );
+               // Purge CDN for this page only
+               $title->purgeSquid();
+               // Clear file cache for this page only
+               HTMLFileCache::clearFileCache( $title );
 
                // Purge ?action=info cache
                $revid = $revision ? $revision->getId() : null;