Add small HtmlCacheUpdater service class to normalize purging code
[lhc/web/wiklou.git] / includes / Title.php
index 12d6641..674767d 100644 (file)
@@ -182,7 +182,8 @@ class Title implements LinkTarget, IDBAccessObject {
        private $mPageLanguage = false;
 
        /** @var string|bool|null The page language code from the database, null if not saved in
-        * the database or false if not loaded, yet. */
+        * the database or false if not loaded, yet.
+        */
        private $mDbPageLanguage = false;
 
        /** @var TitleValue|null A corresponding TitleValue object */
@@ -3431,12 +3432,10 @@ class Title implements LinkTarget, IDBAccessObject {
 
        /**
         * Purge all applicable CDN URLs
+        * @deprecated 1.34 Use HtmlCacheUpdater
         */
        public function purgeSquid() {
-               DeferredUpdates::addUpdate(
-                       new CdnCacheUpdate( $this->getCdnUrls() ),
-                       DeferredUpdates::PRESEND
-               );
+               MediaWikiServices::getInstance()->getHtmlCacheUpdater()->purge( $this->getCdnUrls() );
        }
 
        /**
@@ -4244,12 +4243,21 @@ class Title implements LinkTarget, IDBAccessObject {
         * on the number of links. Typically called on create and delete.
         */
        public function touchLinks() {
-               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks', 'page-touch' ) );
+               $jobs = [];
+               $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
+                       $this,
+                       'pagelinks',
+                       [ 'causeAction' => 'page-touch' ]
+               );
                if ( $this->mNamespace == NS_CATEGORY ) {
-                       DeferredUpdates::addUpdate(
-                               new HTMLCacheUpdate( $this, 'categorylinks', 'category-touch' )
+                       $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
+                               $this,
+                               'categorylinks',
+                               [ 'causeAction' => 'category-touch' ]
                        );
                }
+
+               JobQueueGroup::singleton()->lazyPush( $jobs );
        }
 
        /**