Go to the documentation of this file.
41 const PARSE_THRESHOLD_SEC = 1.0;
43 const CLOCK_FUDGE = 10;
45 const LAG_WAIT_TIMEOUT = 15;
50 $this->removeDuplicates = (
56 $this->params += [
'causeAction' =>
'unknown',
'causeAgent' =>
'unknown' ];
66 $job->command =
'refreshLinksPrioritized';
78 $job->command =
'refreshLinksDynamic';
87 if ( !empty( $this->params[
'recursive'] ) ) {
91 if ( !isset( $this->params[
'range'] ) ) {
93 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
94 $lbFactory->waitForReplication( [
96 'timeout' => self::LAG_WAIT_TIMEOUT
99 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
100 $stats->increment(
'refreshlinks.lag_wait_failed' );
105 $extraParams[
'triggeredRecursive'] =
true;
107 $extraParams[
'causeAction'] = $this->params[
'causeAction'];
108 $extraParams[
'causeAgent'] = $this->params[
'causeAgent'];
115 [
'params' => $extraParams ]
119 } elseif ( isset( $this->params[
'pages'] ) ) {
120 foreach ( $this->params[
'pages']
as $nsAndKey ) {
121 list( $ns, $dbKey ) = $nsAndKey;
137 $services = MediaWikiServices::getInstance();
138 $stats =
$services->getStatsdDataFactory();
139 $lbFactory =
$services->getDBLoadBalancerFactory();
140 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
143 $page->loadPageData( WikiPage::READ_LATEST );
146 $dbw = $lbFactory->getMainLB()->getConnection(
DB_MASTER );
154 if ( !empty( $this->params[
'triggeringRevisionId'] ) ) {
158 $this->params[
'triggeringRevisionId'],
159 Revision::READ_LATEST
167 $stats->increment(
'refreshlinks.rev_not_found' );
168 $this->
setLastError(
"Revision not found for {$title->getPrefixedDBkey()}" );
170 } elseif ( $revision->getId() != $latest || $revision->getPage() !== $page->getId() ) {
175 $stats->increment(
'refreshlinks.rev_not_current' );
176 $this->
setLastError(
"Revision {$revision->getId()} is not current" );
183 $content = $revision->getContentHandler()->makeEmptyContent();
186 $parserOutput =
false;
187 $parserOptions = $page->makeParserOptions(
'canonical' );
191 if ( isset( $this->params[
'rootJobTimestamp'] ) ) {
192 $opportunistic = !empty( $this->params[
'isOpportunistic'] );
194 $skewedTimestamp = $this->params[
'rootJobTimestamp'];
195 if ( $opportunistic ) {
201 wfTimestamp( TS_UNIX, $skewedTimestamp ) + self::CLOCK_FUDGE
205 if ( $page->getLinksTimestamp() > $skewedTimestamp ) {
207 $stats->increment(
'refreshlinks.update_skipped' );
211 if ( $page->getTouched() >= $this->params[
'rootJobTimestamp'] || $opportunistic ) {
214 $parserOutput =
$services->getParserCache()->getDirty( $page, $parserOptions );
216 || $parserOutput->getCacheRevisionId() != $revision->getId()
217 || $parserOutput->getCacheTime() < $skewedTimestamp
219 $parserOutput =
false;
225 if ( $parserOutput ) {
226 $stats->increment(
'refreshlinks.parser_cached' );
228 $start = microtime(
true );
230 $parserOutput = $content->getParserOutput(
231 $title, $revision->getId(), $parserOptions,
false );
232 $elapsed = microtime(
true ) - $start;
236 if ( $elapsed >= self::PARSE_THRESHOLD_SEC
237 && $page->shouldCheckParserCache( $parserOptions, $revision->getId() )
238 && $parserOutput->isCacheable()
242 $parserOutput, $page, $parserOptions, $ctime, $revision->getId()
245 $stats->increment(
'refreshlinks.parser_uncached' );
248 $updates = $content->getSecondaryDataUpdates(
251 !empty( $this->params[
'useRecursiveLinksUpdate'] ),
258 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
260 foreach ( $updates
as $update ) {
262 $update->setCause( $this->params[
'causeAction'], $this->params[
'causeAgent'] );
267 $update->setRevision( $revision );
268 if ( !empty( $this->params[
'triggeringUser'] ) ) {
269 $userInfo = $this->params[
'triggeringUser'];
270 if ( $userInfo[
'userId'] ) {
276 $update->setTriggeringUser(
$user );
281 foreach ( $updates
as $update ) {
282 $update->setTransactionTicket( $ticket );
290 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
296 $info = parent::getDeduplicationInfo();
297 unset( $info[
'causeAction'] );
298 unset( $info[
'causeAgent'] );
299 if ( is_array( $info[
'params'] ) ) {
302 if ( isset( $info[
'params'][
'pages'] ) ) {
303 unset( $info[
'namespace'] );
304 unset( $info[
'title'] );
312 if ( !empty( $this->params[
'recursive'] ) ) {
314 } elseif ( isset( $this->params[
'pages'] ) ) {
315 return count( $this->params[
'pages'] );
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static newFromId( $id)
Static factory method for creation from a given user ID.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
static acquirePageLock(IDatabase $dbw, $pageId, $why='atomicity')
Acquire a lock for performing link table updates for a page on a DB.
the array() calling protocol came about after MediaWiki 1.4rc1.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
__construct(Title $title, array $params)
getDeduplicationInfo()
Subclasses may need to override this to make duplication detection work.
Class the manages updates of *_link tables as well as similar extension-managed tables.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newDynamic(Title $title, array $params)
static newPrioritized(Title $title, array $params)
array $params
Array of job parameters.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static partitionBacklinkJob(Job $job, $bSize, $cSize, $opts=[])
Break down $job into approximately ($bSize/$cSize) leaf jobs and a single partition job that covers t...
Class to both describe a background job and handle jobs.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
when a variable name is used in a it is silently declared as a new masking the global
$wgUpdateRowsPerJob
Number of rows to update per job.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Job to update link tables for pages.
getLatestRevID( $flags=0)
What is the page_latest field for this page?
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
Represents a title within MediaWiki.
static singleton( $domain=false)
if(count( $args)< 1) $job
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static invalidateCache(Title $title, $revid=null)
Clear the info cache for a given Title.
runForTitle(Title $title)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e