ApiQueryBase: Fix addWhereFld for PHP 7.2
[lhc/web/wiklou.git] / includes / deferred / HTMLCacheUpdate.php
index 20e4a4c..29846bf 100644 (file)
@@ -26,7 +26,7 @@
  *
  * @ingroup Cache
  */
-class HTMLCacheUpdate implements DeferrableUpdate {
+class HTMLCacheUpdate extends DataUpdate {
        /** @var Title */
        public $mTitle;
 
@@ -36,32 +36,25 @@ class HTMLCacheUpdate implements DeferrableUpdate {
        /**
         * @param Title $titleTo
         * @param string $table
+        * @param string $causeAction Triggering action
+        * @param string $causeAgent Triggering user
         */
-       function __construct( Title $titleTo, $table ) {
+       function __construct(
+               Title $titleTo, $table, $causeAction = 'unknown', $causeAgent = 'unknown'
+       ) {
                $this->mTitle = $titleTo;
                $this->mTable = $table;
+               $this->causeAction = $causeAction;
+               $this->causeAgent = $causeAgent;
        }
 
        public function doUpdate() {
-               $job = new HTMLCacheUpdateJob(
+               $job = HTMLCacheUpdateJob::newForBacklinks(
                        $this->mTitle,
-                       array(
-                               'table' => $this->mTable,
-                               'recursive' => true
-                       ) + Job::newRootJobParams( // "overall" refresh links job info
-                               "htmlCacheUpdate:{$this->mTable}:{$this->mTitle->getPrefixedText()}"
-                       )
+                       $this->mTable,
+                       [ 'causeAction' => $this->getCauseAction(), 'causeAgent' => $this->getCauseAgent() ]
                );
 
-               $count = $this->mTitle->getBacklinkCache()->getNumLinks( $this->mTable, 100 );
-               if ( $count >= 100 ) { // many backlinks
-                       JobQueueGroup::singleton()->lazyPush( $job );
-                       JobQueueGroup::singleton()->deduplicateRootJob( $job );
-               } else { // few backlinks ($count might be off even if 0)
-                       $dbw = wfGetDB( DB_MASTER );
-                       $dbw->onTransactionIdle( function () use ( $job ) {
-                               $job->run(); // just do the purge query now
-                       } );
-               }
+               JobQueueGroup::singleton()->lazyPush( $job );
        }
 }