Merge "tests: Remove unused TableCleanupTest class"
[lhc/web/wiklou.git] / includes / jobqueue / jobs / HTMLCacheUpdateJob.php
index 6b1a1e3..ae35e30 100644 (file)
@@ -29,7 +29,7 @@
  *   - a) Recursive jobs to purge caches for backlink pages for a given title.
  *        These jobs have (recursive:true,table:<table>) set.
  *   - b) Jobs to purge caches for a set of titles (the job title is ignored).
- *           These jobs have (pages:(<page ID>:(<namespace>,<title>),...) set.
+ *        These jobs have (pages:(<page ID>:(<namespace>,<title>),...) set.
  *
  * @ingroup JobQueue
  */
@@ -40,6 +40,23 @@ class HTMLCacheUpdateJob extends Job {
                $this->removeDuplicates = ( !isset( $params['range'] ) && !isset( $params['pages'] ) );
        }
 
+       /**
+        * @param Title $title Title to purge backlink pages from
+        * @param string $table Backlink table name
+        * @return HTMLCacheUpdateJob
+        */
+       public static function newForBacklinks( Title $title, $table ) {
+               return new self(
+                       $title,
+                       array(
+                               'table' => $table,
+                               'recursive' => true
+                       ) + Job::newRootJobParams( // "overall" refresh links job info
+                               "htmlCacheUpdate:{$table}:{$title->getPrefixedText()}"
+                       )
+               );
+       }
+
        function run() {
                global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
 
@@ -77,7 +94,7 @@ class HTMLCacheUpdateJob extends Job {
         * @param array $pages Map of (page ID => (namespace, DB key)) entries
         */
        protected function invalidateTitles( array $pages ) {
-               global $wgUpdateRowsPerQuery, $wgUseFileCache, $wgUseSquid;
+               global $wgUpdateRowsPerQuery, $wgUseFileCache;
 
                // Get all page IDs in this query into an array
                $pageIds = array_keys( $pages );
@@ -123,10 +140,8 @@ class HTMLCacheUpdateJob extends Job {
                ) );
 
                // Update squid
-               if ( $wgUseSquid ) {
-                       $u = SquidUpdate::newFromTitles( $titleArray );
-                       $u->doUpdate();
-               }
+               $u = SquidUpdate::newFromTitles( $titleArray );
+               $u->doUpdate();
 
                // Update file cache
                if ( $wgUseFileCache ) {