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 $dbProvider = $services->getConnectionProvider();
143 $dbw = $dbProvider->getPrimaryDatabase();
144 $ticket = $dbProvider->getEmptyTransactionTicket( __METHOD__ );
147 $batches = array_chunk( $pageIds, $config->get( MainConfigNames::UpdateRowsPerQuery ) );
148 foreach ( $batches as $batch ) {
149 $dbw->newUpdateQueryBuilder()
151 ->set( [
'page_touched' => $dbw->timestamp( $newTouchedUnix ) ] )
152 ->where( [
'page_id' => $batch ] )
153 ->andWhere( $dbw->expr(
'page_touched',
'<', $dbw->timestamp( $casTsUnix ) ) )
154 ->caller( __METHOD__ )->execute();
155 if ( count( $batches ) > 1 ) {
156 $dbProvider->commitAndWaitForReplication( __METHOD__, $ticket );
160 $queryBuilder = $dbw->newSelectQueryBuilder()
161 ->select( [
'page_namespace',
'page_title' ] )
163 ->where( [
'page_id' => $pageIds,
'page_touched' => $dbw->timestamp( $newTouchedUnix ) ] );
164 if ( $config->get( MainConfigNames::PageLanguageUseDB ) ) {
165 $queryBuilder->field(
'page_lang' );
167 $titleArray = $services->getTitleFactory()->newTitleArrayFromResult(
168 $queryBuilder->caller( __METHOD__ )->fetchResultSet()
172 $htmlCache = $services->getHtmlCacheUpdater();
173 $htmlCache->purgeTitleUrls(
175 $htmlCache::PURGE_NAIVE | $htmlCache::PURGE_URLS_LINKSUPDATE_ONLY,
176 [ $htmlCache::UNLESS_CACHE_MTIME_AFTER => $casTsUnix + self::NORMAL_MAX_LAG ]