39 private const NORMAL_MAX_LAG = 10;
46 $this->removeDuplicates = (
52 $this->params += [
'causeAction' =>
'unknown',
'causeAgent' =>
'unknown' ];
71 "htmlCacheUpdate:{$table}:{$title->getPrefixedText()}"
76 public function run() {
77 $updateRowsPerJob = MediaWikiServices::getInstance()->getMainConfig()->get(
78 MainConfigNames::UpdateRowsPerJob );
79 $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get(
80 MainConfigNames::UpdateRowsPerQuery );
81 if ( isset( $this->params[
'table'] ) && !isset( $this->params[
'pages'] ) ) {
82 $this->params[
'recursive'] =
true;
86 if ( !empty( $this->params[
'recursive'] ) ) {
90 $extraParams[
'causeAction'] = $this->params[
'causeAction'];
91 $extraParams[
'causeAgent'] = $this->params[
'causeAgent'];
99 [
'params' => $extraParams ]
101 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
103 } elseif ( isset( $this->params[
'pages'] ) ) {
109 $t->getArticleID() => [
$t->getNamespace(),
$t->getDBkey() ]
121 $pageIds = array_keys( $pages );
126 $rootTsUnix =
wfTimestampOrNull( TS_UNIX, $this->params[
'rootJobTimestamp'] ??
null );
135 $newTouchedUnix = time();
137 $casTsUnix = $rootTsUnix ?? $newTouchedUnix;
139 $services = MediaWikiServices::getInstance();
140 $config = $services->getMainConfig();
142 $lbFactory = $services->getDBLoadBalancerFactory();
143 $dbw = $lbFactory->getMainLB()->getConnectionRef(
DB_PRIMARY );
144 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
147 $batches = array_chunk( $pageIds, $config->get( MainConfigNames::UpdateRowsPerQuery ) );
148 foreach ( $batches as $batch ) {
149 $dbw->update(
'page',
150 [
'page_touched' => $dbw->timestamp( $newTouchedUnix ) ],
153 "page_touched < " . $dbw->addQuotes( $dbw->timestamp( $casTsUnix ) )
157 if ( count( $batches ) > 1 ) {
158 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
165 [
'page_namespace',
'page_title' ],
166 $config->get( MainConfigNames::PageLanguageUseDB ) ? [
'page_lang' ] : []
168 [
'page_id' => $pageIds,
'page_touched' => $dbw->timestamp( $newTouchedUnix ) ],
173 $htmlCache = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
174 $htmlCache->purgeTitleUrls(
176 $htmlCache::PURGE_NAIVE | $htmlCache::PURGE_URLS_LINKSUPDATE_ONLY,
177 [ $htmlCache::UNLESS_CACHE_MTIME_AFTER => $casTsUnix + self::NORMAL_MAX_LAG ]
182 $info = parent::getDeduplicationInfo();
183 if ( is_array( $info[
'params'] ) ) {
186 if ( isset( $info[
'params'][
'pages'] ) ) {
187 unset( $info[
'namespace'] );
188 unset( $info[
'title'] );
196 if ( !empty( $this->params[
'recursive'] ) ) {
198 } elseif ( isset( $this->params[
'pages'] ) ) {
199 return count( $this->params[
'pages'] );
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
static partitionBacklinkJob(Job $job, $bSize, $cSize, $opts=[])
Break down $job into approximately ($bSize/$cSize) leaf jobs and a single partition job that covers t...
Job to purge the HTML/file cache for all pages that link to or use another page or file.
getDeduplicationInfo()
Subclasses may need to override this to make duplication detection work.
__construct(Title $title, array $params)
static newForBacklinks(PageReference $page, $table, $params=[])
invalidateTitles(array $pages)
Class to both describe a background job and handle jobs.
array $params
Array of job parameters.
static newRootJobParams( $key)
Get "root job" parameters for a task.
A class containing constants representing the names of configuration variables.
static newFromResult( $res)
Represents a title within MediaWiki.
static castFromPageReference(?PageReference $pageReference)
Return a Title for a given Reference.