*/
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;
public function doUpdate() {
Hooks::run( 'LinksUpdate', array( &$this ) );
$this->doIncrementalUpdate();
- Hooks::run( 'LinksUpdateComplete', array( &$this ) );
+
+ $that = $this;
+ $this->mDb->onTransactionIdle( function() use ( $that ) {
+ Hooks::run( 'LinksUpdateComplete', array( &$that ) );
+ } );
}
protected function doIncrementalUpdate() {
// 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 );
}
$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
$inv = array( $inv );
}
foreach ( $inv as $table ) {
- $update = new HTMLCacheUpdate( $this->mTitle, $table );
- $update->doUpdate();
+ DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
}
}
}
}
public function getAsJobSpecification() {
+ if ( $this->user ) {
+ $userInfo = array(
+ 'userId' => $this->user->getId(),
+ 'userName' => $this->user->getName(),
+ );
+ } else {
+ $userInfo = false;
+ }
+
+ if ( $this->mRevision ) {
+ $triggeringRevisionId = $this->mRevision->getId();
+ } else {
+ $triggeringRevisionId = 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,
+ 'triggeringRevisionId' => $triggeringRevisionId,
+ ),
array( 'removeDuplicates' => true ),
$this->getTitle()
)