77 public function run() {
78 $updateRowsPerJob = MediaWikiServices::getInstance()->getMainConfig()->get(
79 MainConfigNames::UpdateRowsPerJob );
80 $updateRowsPerQuery = MediaWikiServices::getInstance()->getMainConfig()->get(
81 MainConfigNames::UpdateRowsPerQuery );
82 if ( isset( $this->params[
'table'] ) && !isset( $this->params[
'pages'] ) ) {
83 $this->params[
'recursive'] =
true;
87 if ( !empty( $this->params[
'recursive'] ) ) {
91 $extraParams[
'causeAction'] = $this->params[
'causeAction'];
92 $extraParams[
'causeAgent'] = $this->params[
'causeAgent'];
100 [
'params' => $extraParams ]
102 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
104 } elseif ( isset( $this->params[
'pages'] ) ) {
110 $t->getArticleID() => [ $t->getNamespace(), $t->getDBkey() ]
122 $pageIds = array_keys( $pages );
127 $rootTsUnix =
wfTimestampOrNull( TS_UNIX, $this->params[
'rootJobTimestamp'] ??
null );
136 $newTouchedUnix = time();
138 $casTsUnix = $rootTsUnix ?? $newTouchedUnix;
140 $services = MediaWikiServices::getInstance();
141 $config = $services->getMainConfig();
143 $lbFactory = $services->getDBLoadBalancerFactory();
144 $dbw = $lbFactory->getPrimaryDatabase();
145 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
148 $batches = array_chunk( $pageIds, $config->get( MainConfigNames::UpdateRowsPerQuery ) );
149 foreach ( $batches as $batch ) {
150 $dbw->newUpdateQueryBuilder()
152 ->set( [
'page_touched' => $dbw->timestamp( $newTouchedUnix ) ] )
153 ->where( [
'page_id' => $batch ] )
154 ->andWhere( $dbw->expr(
'page_touched',
'<', $dbw->timestamp( $casTsUnix ) ) )
155 ->caller( __METHOD__ )->execute();
156 if ( count( $batches ) > 1 ) {
157 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
161 $queryBuilder = $dbw->newSelectQueryBuilder()
162 ->select( [
'page_namespace',
'page_title' ] )
164 ->where( [
'page_id' => $pageIds,
'page_touched' => $dbw->timestamp( $newTouchedUnix ) ] );
165 if ( $config->get( MainConfigNames::PageLanguageUseDB ) ) {
166 $queryBuilder->field(
'page_lang' );
168 $titleArray =
new TitleArrayFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() );
171 $htmlCache = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
172 $htmlCache->purgeTitleUrls(
174 $htmlCache::PURGE_NAIVE | $htmlCache::PURGE_URLS_LINKSUPDATE_ONLY,
175 [ $htmlCache::UNLESS_CACHE_MTIME_AFTER => $casTsUnix + self::NORMAL_MAX_LAG ]