MediaWiki
REL1_35
RefreshSecondaryDataUpdate.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\Revision\RevisionRecord
;
24
use
MediaWiki\Storage\DerivedPageDataUpdater
;
25
use
Wikimedia\Rdbms\ILBFactory
;
26
35
class
RefreshSecondaryDataUpdate
extends
DataUpdate
36
implements
TransactionRoundAwareUpdate
,
EnqueueableDataUpdate
37
{
39
private
$lbFactory
;
41
private
$page
;
43
private
$updater
;
45
private
$recursive
;
46
48
private
$revisionRecord
;
50
private
$user
;
51
60
public
function
__construct
(
61
ILBFactory
$lbFactory,
62
User
$user,
63
WikiPage
$page,
64
RevisionRecord
$revisionRecord,
65
DerivedPageDataUpdater
$updater,
66
array $options
67
) {
68
parent::__construct();
69
70
$this->lbFactory = $lbFactory;
71
$this->user = $user;
72
$this->page = $page;
73
$this->revisionRecord = $revisionRecord;
74
$this->updater = $updater;
75
$this->recursive = !empty( $options[
'recursive'
] );
76
}
77
78
public
function
getTransactionRoundRequirement
() {
79
return
self::TRX_ROUND_ABSENT;
80
}
81
82
public
function
doUpdate
() {
83
$updates = $this->updater->getSecondaryDataUpdates( $this->recursive );
84
foreach
( $updates as $update ) {
85
if
( $update instanceof
LinksUpdate
) {
86
$update->setRevisionRecord( $this->revisionRecord );
87
$update->setTriggeringUser( $this->user );
88
}
89
if
( $update instanceof
DataUpdate
) {
90
$update->setCause( $this->causeAction, $this->causeAgent );
91
}
92
}
93
94
// T221577, T248003: flush any transaction; each update needs outer transaction scope
95
// and the code above may have implicitly started one.
96
$this->lbFactory->commitMasterChanges( __METHOD__ );
97
98
$e =
null
;
99
foreach
( $updates as $update ) {
100
try
{
101
DeferredUpdates::attemptUpdate( $update, $this->lbFactory );
102
}
catch
( Exception $e ) {
103
// Try as many updates as possible on the first pass
104
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
105
}
106
}
107
108
if
( $e instanceof Exception ) {
109
throw
$e;
// trigger RefreshLinksJob enqueue via getAsJobSpecification()
110
}
111
}
112
113
public
function
getAsJobSpecification
() {
114
return
[
115
'domain'
=> $this->lbFactory->getLocalDomainID(),
116
'job'
=>
new
JobSpecification
(
117
'refreshLinksPrioritized'
,
118
[
119
'namespace'
=> $this->page->getTitle()->getNamespace(),
120
'title'
=> $this->page->getTitle()->getDBkey(),
121
// Reuse the parser cache if it was saved
122
'rootJobTimestamp'
=> $this->revisionRecord
123
? $this->revisionRecord->getTimestamp()
124
:
null
,
125
'useRecursiveLinksUpdate'
=> $this->recursive,
126
'triggeringUser'
=> $this->user
127
? [
128
'userId'
=> $this->user->getId(),
129
'userName'
=> $this->user->getName()
130
]
131
:
null
,
132
'triggeringRevisionId'
=> $this->revisionRecord
133
? $this->revisionRecord->getId()
134
:
null
,
135
'causeAction'
=> $this->
getCauseAction
(),
136
'causeAgent'
=> $this->
getCauseAgent
()
137
],
138
[
'removeDuplicates'
=>
true
]
139
)
140
];
141
}
142
}
DataUpdate
Abstract base class for update jobs that do something with some secondary data extracted from article...
Definition
DataUpdate.php:30
DataUpdate\getCauseAgent
getCauseAgent()
Definition
DataUpdate.php:72
DataUpdate\getCauseAction
getCauseAction()
Definition
DataUpdate.php:65
JobSpecification
Job queue task description base code.
Definition
JobSpecification.php:39
LinksUpdate
Class the manages updates of *_link tables as well as similar extension-managed tables.
Definition
LinksUpdate.php:37
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition
RevisionRecord.php:46
MediaWiki\Storage\DerivedPageDataUpdater
A handle for managing updates for derived page data on edit, import, purge, etc.
Definition
DerivedPageDataUpdater.php:103
RefreshSecondaryDataUpdate
Update object handling the cleanup of secondary data after a page was edited.
Definition
RefreshSecondaryDataUpdate.php:37
RefreshSecondaryDataUpdate\__construct
__construct(ILBFactory $lbFactory, User $user, WikiPage $page, RevisionRecord $revisionRecord, DerivedPageDataUpdater $updater, array $options)
Definition
RefreshSecondaryDataUpdate.php:60
RefreshSecondaryDataUpdate\$revisionRecord
RevisionRecord null $revisionRecord
Definition
RefreshSecondaryDataUpdate.php:48
RefreshSecondaryDataUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition
RefreshSecondaryDataUpdate.php:82
RefreshSecondaryDataUpdate\getAsJobSpecification
getAsJobSpecification()
Definition
RefreshSecondaryDataUpdate.php:113
RefreshSecondaryDataUpdate\$recursive
bool $recursive
Definition
RefreshSecondaryDataUpdate.php:45
RefreshSecondaryDataUpdate\$page
WikiPage $page
Definition
RefreshSecondaryDataUpdate.php:41
RefreshSecondaryDataUpdate\$updater
DerivedPageDataUpdater $updater
Definition
RefreshSecondaryDataUpdate.php:43
RefreshSecondaryDataUpdate\$lbFactory
ILBFactory $lbFactory
Definition
RefreshSecondaryDataUpdate.php:39
RefreshSecondaryDataUpdate\$user
User null $user
Definition
RefreshSecondaryDataUpdate.php:50
RefreshSecondaryDataUpdate\getTransactionRoundRequirement
getTransactionRoundRequirement()
Definition
RefreshSecondaryDataUpdate.php:78
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition
User.php:60
WikiPage
Class representing a MediaWiki article and history.
Definition
WikiPage.php:51
EnqueueableDataUpdate
Interface that marks a DataUpdate as enqueuable via the JobQueue.
Definition
EnqueueableDataUpdate.php:12
TransactionRoundAwareUpdate
Deferrable update that specifies whether it must run outside of any explicit LBFactory transaction ro...
Definition
TransactionRoundAwareUpdate.php:11
Wikimedia\Rdbms\ILBFactory
An interface for generating database load balancers.
Definition
ILBFactory.php:33
true
return true
Definition
router.php:92
includes
deferred
RefreshSecondaryDataUpdate.php
Generated on Sat Apr 6 2024 00:07:05 for MediaWiki by
1.9.8