MediaWiki
REL1_40
RefreshSecondaryDataUpdate.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\Deferred\LinksUpdate\LinksUpdate
;
24
use
MediaWiki\Revision\RevisionRecord
;
25
use
MediaWiki\Storage\DerivedPageDataUpdater
;
26
use
MediaWiki\User\UserIdentity
;
27
use
Wikimedia\Rdbms\ILBFactory
;
28
37
class
RefreshSecondaryDataUpdate
extends
DataUpdate
38
implements
TransactionRoundAwareUpdate
,
EnqueueableDataUpdate
39
{
41
private
$lbFactory;
43
private
$page;
45
private
$updater;
47
private
$recursive;
48
50
private
$revisionRecord;
52
private
$user;
53
62
public
function
__construct
(
63
ILBFactory
$lbFactory,
64
UserIdentity
$user,
65
WikiPage
$page,
66
RevisionRecord
$revisionRecord,
67
DerivedPageDataUpdater
$updater,
68
array $options
69
) {
70
parent::__construct();
71
72
$this->lbFactory = $lbFactory;
73
$this->user = $user;
74
$this->page = $page;
75
$this->revisionRecord = $revisionRecord;
76
$this->updater = $updater;
77
$this->recursive = !empty( $options[
'recursive'
] );
78
}
79
80
public
function
getTransactionRoundRequirement
() {
81
return
self::TRX_ROUND_ABSENT;
82
}
83
84
public
function
doUpdate
() {
85
$updates = $this->updater->getSecondaryDataUpdates( $this->recursive );
86
foreach
( $updates as $update ) {
87
if
( $update instanceof
LinksUpdate
) {
88
$update->setRevisionRecord( $this->revisionRecord );
89
$update->setTriggeringUser( $this->user );
90
}
91
if
( $update instanceof
DataUpdate
) {
92
$update->setCause( $this->causeAction, $this->causeAgent );
93
}
94
}
95
96
// T221577, T248003: flush any transaction; each update needs outer transaction scope
97
// and the code above may have implicitly started one.
98
$this->lbFactory->commitPrimaryChanges( __METHOD__ );
99
100
$e =
null
;
101
foreach
( $updates as $update ) {
102
try
{
103
DeferredUpdates::attemptUpdate( $update, $this->lbFactory );
104
}
catch
( Exception $e ) {
105
// Try as many updates as possible on the first pass
106
MWExceptionHandler::rollbackPrimaryChangesAndLog( $e );
107
}
108
}
109
110
if
( $e instanceof Exception ) {
111
throw
$e;
// trigger RefreshLinksJob enqueue via getAsJobSpecification()
112
}
113
}
114
115
public
function
getAsJobSpecification
() {
116
return
[
117
'domain'
=> $this->lbFactory->getLocalDomainID(),
118
'job'
=>
new
JobSpecification
(
119
'refreshLinksPrioritized'
,
120
[
121
'namespace'
=> $this->page->getTitle()->getNamespace(),
122
'title'
=> $this->page->getTitle()->getDBkey(),
123
// Reuse the parser cache if it was saved
124
'rootJobTimestamp'
=> $this->revisionRecord
125
? $this->revisionRecord->getTimestamp()
126
:
null
,
127
'useRecursiveLinksUpdate'
=> $this->recursive,
128
'triggeringUser'
=> $this->user
129
? [
130
'userId'
=> $this->user->getId(),
131
'userName'
=> $this->user->getName()
132
]
133
:
null
,
134
'triggeringRevisionId'
=> $this->revisionRecord
135
? $this->revisionRecord->getId()
136
:
null
,
137
'causeAction'
=> $this->
getCauseAction
(),
138
'causeAgent'
=> $this->
getCauseAgent
()
139
],
140
[
'removeDuplicates'
=>
true
]
141
)
142
];
143
}
144
}
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:43
MediaWiki\Deferred\LinksUpdate\LinksUpdate
Class the manages updates of *_link tables as well as similar extension-managed tables.
Definition
LinksUpdate.php:55
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition
RevisionRecord.php:47
MediaWiki\Storage\DerivedPageDataUpdater
A handle for managing updates for derived page data on edit, import, purge, etc.
Definition
DerivedPageDataUpdater.php:107
RefreshSecondaryDataUpdate
Update object handling the cleanup of secondary data after a page was edited.
Definition
RefreshSecondaryDataUpdate.php:39
RefreshSecondaryDataUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition
RefreshSecondaryDataUpdate.php:84
RefreshSecondaryDataUpdate\getAsJobSpecification
getAsJobSpecification()
Definition
RefreshSecondaryDataUpdate.php:115
RefreshSecondaryDataUpdate\__construct
__construct(ILBFactory $lbFactory, UserIdentity $user, WikiPage $page, RevisionRecord $revisionRecord, DerivedPageDataUpdater $updater, array $options)
Definition
RefreshSecondaryDataUpdate.php:62
RefreshSecondaryDataUpdate\getTransactionRoundRequirement
getTransactionRoundRequirement()
Definition
RefreshSecondaryDataUpdate.php:80
WikiPage
Base representation for an editable wiki page.
Definition
WikiPage.php:75
EnqueueableDataUpdate
Interface that marks a DataUpdate as enqueuable via the JobQueue.
Definition
EnqueueableDataUpdate.php:12
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition
UserIdentity.php:39
TransactionRoundAwareUpdate
Deferrable update that specifies whether it must run outside of any explicit LBFactory transaction ro...
Definition
TransactionRoundAwareUpdate.php:11
Wikimedia\Rdbms\ILBFactory
Manager of ILoadBalancer objects and, indirectly, IDatabase connections.
Definition
ILBFactory.php:46
true
return true
Definition
router.php:92
includes
deferred
RefreshSecondaryDataUpdate.php
Generated on Thu Jun 27 2024 14:02:38 for MediaWiki by
1.10.0