/** @var bool Whether to queue jobs for recursive updates */
public $mRecursive;
+ /** @var bool Whether this job was triggered by a recursive update job */
+ private $mTriggeredRecursive;
+
+ /** @var Revision Revision for which this update has been triggered */
+ private $mRevision;
+
/**
* @var null|array Added links if calculated.
*/
*/
private $linkDeletions = null;
+ /**
+ * @var User|null
+ */
+ private $user;
+
/**
* Constructor
*
* @param bool $recursive Queue jobs for recursive updates?
* @throws MWException
*/
- function __construct( $title, $parserOutput, $recursive = true ) {
+ function __construct( Title $title, ParserOutput $parserOutput, $recursive = true ) {
parent::__construct( false ); // no implicit transaction
- if ( !( $title instanceof Title ) ) {
- throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " .
- "Please see Article::editUpdates() for an invocation example.\n" );
- }
-
- if ( !( $parserOutput instanceof ParserOutput ) ) {
- throw new MWException( "The calling convention to LinksUpdate::__construct() has changed. " .
- "Please see WikiPage::doEditUpdates() for an invocation example.\n" );
- }
-
$this->mTitle = $title;
$this->mId = $title->getArticleID();
if ( !$this->mId ) {
- throw new MWException( "The Title object did not provide an article " .
- "ID. Perhaps the page doesn't exist?" );
+ throw new InvalidArgumentException(
+ "The Title object yields no ID. Perhaps the page doesn't exist?"
+ );
}
$this->mParserOutput = $parserOutput;
}
protected function doIncrementalUpdate() {
+ global $wgRCWatchCategoryMembership;
# Page links
$existing = $this->getExistingLinks();
$this->invalidateCategories( $categoryUpdates );
$this->updateCategoryCounts( $categoryInserts, $categoryDeletes );
+ # Category membership changes
+ if (
+ $wgRCWatchCategoryMembership &&
+ !$this->mTriggeredRecursive && ( $categoryInserts || $categoryDeletes )
+ ) {
+ $this->triggerCategoryChanges( $categoryInserts, $categoryDeletes );
+ }
+
# Page properties
$existing = $this->getExistingProperties();
}
+ private function triggerCategoryChanges( $categoryInserts, $categoryDeletes ) {
+ $catMembChange = new CategoryMembershipChange( $this->mTitle, $this->mRevision );
+
+ if ( $this->mRecursive ) {
+ $catMembChange->checkTemplateLinks();
+ }
+
+ foreach ( $categoryInserts as $categoryName => $value ) {
+ $categoryTitle = Title::newFromText( $categoryName, NS_CATEGORY );
+ $catMembChange->triggerCategoryAddedNotification( $categoryTitle );
+ }
+
+ foreach ( $categoryDeletes as $categoryName => $value ) {
+ $categoryTitle = Title::newFromText( $categoryName, NS_CATEGORY );
+ $catMembChange->triggerCategoryRemovedNotification( $categoryTitle );
+ }
+ }
+
/**
* Queue recursive jobs for this page
*
// Which ever runs first generally no-ops the other one.
$jobs = array();
foreach ( $bc->getCascadeProtectedLinks() as $title ) {
- $jobs[] = new RefreshLinksJob( $title, array( 'prioritize' => true ) );
+ $jobs[] = RefreshLinksJob::newPrioritized( $title, array() );
}
JobQueueGroup::singleton()->push( $jobs );
}
return $this->mImages;
}
+ /**
+ * Set this object as being triggered by a recursive LinksUpdate
+ *
+ * @since 1.27
+ */
+ public function setTriggeredRecursive() {
+ $this->mTriggeredRecursive = true;
+ }
+
+ /**
+ * Set the revision corresponding to this LinksUpdate
+ *
+ * @since 1.27
+ *
+ * @param Revision $revision
+ */
+ public function setRevision( Revision $revision ) {
+ $this->mRevision = $revision;
+ }
+
+ /**
+ * Set the User who triggered this LinksUpdate
+ *
+ * @since 1.27
+ * @param User $user
+ */
+ public function setTriggeringUser( User $user ) {
+ $this->user = $user;
+ }
+
+ /**
+ * @since 1.27
+ * @return null|User
+ */
+ public function getTriggeringUser() {
+ return $this->user;
+ }
+
/**
* Invalidate any necessary link lists related to page property changes
* @param array $changed
}
public function getAsJobSpecification() {
+ if ( $this->user ) {
+ $userInfo = array(
+ 'userId' => $this->user->getId(),
+ 'userName' => $this->user->getName(),
+ );
+ } else {
+ $userInfo = false;
+ }
return array(
'wiki' => $this->mDb->getWikiID(),
'job' => new JobSpecification(
- 'refreshLinks',
- array( 'prioritize' => true ),
+ 'refreshLinksPrioritized',
+ array(
+ // Reuse the parser cache if it was saved
+ 'rootJobTimestamp' => $this->mParserOutput->getCacheTime(),
+ 'useRecursiveLinksUpdate' => $this->mRecursive,
+ 'triggeringUser' => $userInfo,
+ ),
array( 'removeDuplicates' => true ),
$this->getTitle()
)