Go to the documentation of this file.
56 'categoryMembershipChange',
59 'revTimestamp' => $revisionTimestamp,
74 parent::__construct(
'categoryMembershipChange',
$title,
$params );
77 $this->removeDuplicates =
true;
81 public function run() {
82 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
83 $lb = $lbFactory->getMainLB();
86 $this->ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
90 $this->
setLastError(
"Could not find page #{$this->params['pageId']}" );
96 if ( !$lb->safeWaitForMasterPos(
$dbr ) ) {
97 $this->
setLastError(
"Timed out while pre-waiting for replica DB to catch up" );
102 $lockKey =
"CategoryMembershipUpdates:{$page->getId()}";
103 $scopedLock = $dbw->getScopedLockAndFlush( $lockKey, __METHOD__, 3 );
104 if ( !$scopedLock ) {
105 $this->
setLastError(
"Could not acquire lock '$lockKey'" );
110 if ( !$lb->safeWaitForMasterPos(
$dbr ) ) {
111 $this->
setLastError(
"Timed out while waiting for replica DB to catch up" );
115 $dbr->flushSnapshot( __METHOD__ );
117 $cutoffUnix =
wfTimestamp( TS_UNIX, $this->params[
'revTimestamp'] );
124 $row =
$dbr->selectRow(
126 [
'rev_timestamp',
'rev_id' ],
128 'rev_page' => $page->getId(),
129 'rev_timestamp >= ' .
$dbr->addQuotes(
$dbr->timestamp( $cutoffUnix ) ),
130 'EXISTS (' .
$dbr->selectSQLText(
134 'rc_this_oldid = rev_id',
137 'rc_cur_id = rev_page',
138 'rc_timestamp = rev_timestamp'
143 [
'ORDER BY' =>
'rev_timestamp DESC, rev_id DESC' ]
147 $cutoffUnix =
wfTimestamp( TS_UNIX, $row->rev_timestamp );
148 $lastRevId = (int)$row->rev_id;
155 $encCutoff =
$dbr->addQuotes(
$dbr->timestamp( $cutoffUnix ) );
161 'rev_page' => $page->getId(),
162 "rev_timestamp > $encCutoff" .
163 " OR (rev_timestamp = $encCutoff AND rev_id > $lastRevId)"
166 [
'ORDER BY' =>
'rev_timestamp ASC, rev_id ASC' ],
171 foreach (
$res as $row ) {
191 if ( !
$newRev->getContent() ) {
196 if (
$newRev->getParentId() ) {
198 if ( !$oldRev || !$oldRev->getContent() ) {
207 list( $categoryInserts, $categoryDeletes ) = $categoryChanges;
208 if ( !$categoryInserts && !$categoryDeletes ) {
213 $catMembChange->checkTemplateLinks();
215 $batchSize = $config->get(
'UpdateRowsPerQuery' );
218 foreach ( $categoryInserts
as $categoryName ) {
220 $catMembChange->triggerCategoryAddedNotification( $categoryTitle );
221 if ( $insertCount++ && ( $insertCount % $batchSize ) == 0 ) {
226 foreach ( $categoryDeletes
as $categoryName ) {
228 $catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
229 if ( $insertCount++ && ( $insertCount++ % $batchSize ) == 0 ) {
241 $parseTimestamp =
$newRev->getTimestamp();
245 $oldCategories = $oldRev
251 $categoryInserts = array_values( array_diff( $newCategories, $oldCategories ) );
252 $categoryDeletes = array_values( array_diff( $oldCategories, $newCategories ) );
254 return [ $categoryInserts, $categoryDeletes ];
265 $renderer = MediaWikiServices::getInstance()->getRevisionRenderer();
267 $options->setTimestamp( $parseTimestamp );
273 ->getRevisionParserOutput();
278 return array_map(
'strval', array_keys(
$output->getCategories() ) );
282 $info = parent::getDeduplicationInfo();
283 unset( $info[
'params'][
'revTimestamp'] );
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Class representing a MediaWiki article and history.
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
getDeduplicationInfo()
Subclasses may need to override this to make duplication detection work.
array $params
Array of job parameters.
getExplicitCategoriesChanges(WikiPage $page, Revision $newRev, Revision $oldRev=null)
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
Class to both describe a background job and handle jobs.
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
__construct(ParserCache $parserCache, Title $title, array $params)
Constructor for use by the Job Queue infrastructure.
getCategoriesAtRev(WikiPage $page, Revision $rev, $parseTimestamp)
getTitle()
Get the title object of the article.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
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
Job to add recent change entries mentioning category membership changes.
static newFromID( $id, $from='fromdb')
Constructor from a page id.
static getMain()
Get the RequestContext object associated with the main request.
Represents a title within MediaWiki.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Job queue task description base code.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
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
notifyUpdatesForRevision(LBFactory $lbFactory, WikiPage $page, Revision $newRev)
static newSpec(Title $title, $revisionTimestamp)
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