*
* See docs/deferred.txt
*/
-class LinksUpdate extends DataUpdate {
+class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
// @todo make members protected, but make sure extensions don't break
/** @var int Page ID of the article linked from */
parent::__construct();
$this->mTitle = $title;
- $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
+
+ if ( !$this->mId ) {
+ // NOTE: subclasses may initialize mId before calling this constructor!
+ $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
+ }
if ( !$this->mId ) {
throw new InvalidArgumentException(
$nt = Title::makeTitleSafe( NS_CATEGORY, $name );
$contLang->findVariantLink( $name, $nt, true );
- $type = MWNamespace::getCategoryLinkType( $this->mTitle->getNamespace() );
+ $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCategoryLinkType( $this->mTitle->getNamespace() );
# Treat custom sortkeys as a prefix, so that if multiple
# things are forced to sort as '*' or something, they'll
/**
* @return IDatabase
*/
- private function getDB() {
+ protected function getDB() {
if ( !$this->db ) {
$this->db = wfGetDB( DB_MASTER );
}
return $this->db;
}
+
+ public function getAsJobSpecification() {
+ if ( $this->user ) {
+ $userInfo = [
+ 'userId' => $this->user->getId(),
+ 'userName' => $this->user->getName(),
+ ];
+ } else {
+ $userInfo = false;
+ }
+
+ if ( $this->mRevision ) {
+ $triggeringRevisionId = $this->mRevision->getId();
+ } else {
+ $triggeringRevisionId = false;
+ }
+
+ return [
+ 'domain' => $this->getDB()->getDomainID(),
+ 'job' => new JobSpecification(
+ 'refreshLinksPrioritized',
+ [
+ // Reuse the parser cache if it was saved
+ 'rootJobTimestamp' => $this->mParserOutput->getCacheTime(),
+ 'useRecursiveLinksUpdate' => $this->mRecursive,
+ 'triggeringUser' => $userInfo,
+ 'triggeringRevisionId' => $triggeringRevisionId,
+ 'causeAction' => $this->getCauseAction(),
+ 'causeAgent' => $this->getCauseAgent()
+ ],
+ [ 'removeDuplicates' => true ],
+ $this->getTitle()
+ )
+ ];
+ }
}