3 * Updater for secondary data after a page edit.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * Update object handling the cleanup of secondary data after a page was edited.
26 * This makes makes it possible for DeferredUpdates to have retry logic using a single
27 * refreshLinks job if any of the bundled updates fail.
29 class RefreshSecondaryDataUpdate
extends DataUpdate
implements EnqueueableDataUpdate
{
32 /** @var DeferrableUpdate[] */
37 private $cacheTimestamp;
38 /** @var string Database domain ID */
41 /** @var Revision|null */
47 * @param WikiPage $page Page we are updating
48 * @param DeferrableUpdate[] $updates Updates from DerivedPageDataUpdater::getSecondaryUpdates()
49 * @param array $options Options map (causeAction, causeAgent, recursive)
50 * @param string $cacheTime Result of ParserOutput::getCacheTime() for the source output
51 * @param string $domain The database domain ID of the wiki the update is for
60 parent
::__construct();
63 $this->updates
= $updates;
64 $this->causeAction
= $options['causeAction'] ??
'unknown';
65 $this->causeAgent
= $options['causeAgent'] ??
'unknown';
66 $this->recursive
= !empty( $options['recursive'] );
67 $this->cacheTimestamp
= $cacheTime;
68 $this->domain
= $domain;
71 public function doUpdate() {
72 foreach ( $this->updates
as $update ) {
78 * Set the revision corresponding to this LinksUpdate
79 * @param Revision $revision
81 public function setRevision( Revision
$revision ) {
82 $this->revision
= $revision;
86 * Set the User who triggered this LinksUpdate
89 public function setTriggeringUser( User
$user ) {
93 public function getAsJobSpecification() {
95 'wiki' => WikiMap
::getWikiIdFromDomain( $this->domain
),
96 'job' => new JobSpecification(
97 'refreshLinksPrioritized',
99 // Reuse the parser cache if it was saved
100 'rootJobTimestamp' => $this->cacheTimestamp
,
101 'useRecursiveLinksUpdate' => $this->recursive
,
102 'triggeringUser' => $this->user
104 'userId' => $this->user
->getId(),
105 'userName' => $this->user
->getName()
108 'triggeringRevisionId' => $this->revision ?
$this->revision
->getId() : false,
109 'causeAction' => $this->getCauseAction(),
110 'causeAgent' => $this->getCauseAgent()
112 [ 'removeDuplicates' => true ],
113 $this->page
->getTitle()