Content::getNativeData() for text-based content models.
* (T210814) SVGs are now by default displayed in wiki language on image
pages.
+* (T214706) LinksUpdate::getAddedExternalLinks() and
+ LinksUpdate::getRemovedExternalLinks() were introduced.
=== External library changes in 1.33 ===
*/
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();
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.
/**
* @covers ParserOutput::addExternalLink
+ * @covers LinksUpdate::getAddedExternalLinks
+ * @covers LinksUpdate::getRemovedExternalLinks
*/
public function testUpdate_externallinks() {
/** @var ParserOutput $po */
$po->addExternalLink( "http://testing.com/wiki/Foo" );
- $this->assertLinksUpdate(
+ $update = $this->assertLinksUpdate(
$t,
$po,
'externallinks',
[ 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ],
]
);
+
+ $this->assertArrayEquals( [
+ "http://testing.com/wiki/Foo"
+ ], $update->getAddedExternalLinks() );
+
+ $po = new ParserOutput();
+ $po->setTitleText( $t->getPrefixedText() );
+ $po->addExternalLink( 'http://testing.com/wiki/Bar' );
+ $update = $this->assertLinksUpdate(
+ $t,
+ $po,
+ 'externallinks',
+ 'el_to, el_index',
+ 'el_from = ' . self::$testingPageId,
+ [
+ [ 'http://testing.com/wiki/Bar', 'http://com.testing./wiki/Bar' ],
+ ]
+ );
+
+ $this->assertArrayEquals( [
+ "http://testing.com/wiki/Bar"
+ ], $update->getAddedExternalLinks() );
+ $this->assertArrayEquals( [
+ "http://testing.com/wiki/Foo"
+ ], $update->getRemovedExternalLinks() );
}
/**