*
* See docs/deferred.txt
*/
-class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
+class LinksUpdate extends DataUpdate {
// @todo make members protected, but make sure extensions don't break
/** @var int Page ID of the article linked from */
*/
private $linkDeletions = null;
+ /**
+ * @var null|array Added external links if calculated.
+ */
+ private $externalLinkInsertions = null;
+
+ /**
+ * @var null|array Deleted external links if calculated.
+ */
+ private $externalLinkDeletions = null;
+
/**
* @var null|array Added properties if calculated.
*/
# External links
$existingEL = $this->getExistingExternals();
+ $this->externalLinkDeletions = $this->getExternalDeletions( $existingEL );
+ $this->externalLinkInsertions = $this->getExternalInsertions(
+ $existingEL );
$this->incrTableUpdate(
'externallinks',
'el',
- $this->getExternalDeletions( $existingEL ),
- $this->getExternalInsertions( $existingEL ) );
+ $this->externalLinkDeletions,
+ $this->externalLinkInsertions );
# Language links
$existingLL = $this->getExistingInterlangs();
* @param array $existing
* @return array
*/
- function getPropertyDeletions( $existing ) {
+ private function getPropertyDeletions( $existing ) {
return array_diff_assoc( $existing, $this->mProperties );
}
return $result;
}
+ /**
+ * Fetch external links added by this LinksUpdate. Only available after
+ * the update is complete.
+ * @since 1.33
+ * @return null|array Array of Strings
+ */
+ public function getAddedExternalLinks() {
+ if ( $this->externalLinkInsertions === null ) {
+ return null;
+ }
+ $result = [];
+ foreach ( $this->externalLinkInsertions as $key => $value ) {
+ $result[] = $value['el_to'];
+ }
+ return $result;
+ }
+
+ /**
+ * Fetch external links removed by this LinksUpdate. Only available after
+ * the update is complete.
+ * @since 1.33
+ * @return null|array Array of Strings
+ */
+ public function getRemovedExternalLinks() {
+ if ( $this->externalLinkDeletions === null ) {
+ return null;
+ }
+ return array_keys( $this->externalLinkDeletions );
+ }
+
/**
* Fetch page properties added by this LinksUpdate.
* Only available after the update is complete.
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 [
- 'wiki' => WikiMap::getWikiIdFromDbDomain( $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()
- )
- ];
- }
}