jenkins-bot has submitted this change and it was merged. Change subject: Rename Redlinker to WikiLinkFixer ......................................................................
Rename Redlinker to WikiLinkFixer This reflects that we're relying on this functionality for more than just red links. Change-Id: Ia3561e085b5b5fd6e739c5a4fe6a8ff576c26e70 --- M autoload.php M container.php M includes/Parsoid/Fixer/BaseHrefFixer.php R includes/Parsoid/Fixer/WikiLinkFixer.php R tests/phpunit/Parsoid/Fixer/WikiLinkFixerTest.php 5 files changed, 18 insertions(+), 21 deletions(-) Approvals: EBernhardson: Looks good to me, approved jenkins-bot: Verified diff --git a/autoload.php b/autoload.php index ed3e21d..efb1bd5 100644 --- a/autoload.php +++ b/autoload.php @@ -257,7 +257,7 @@ 'Flow\\Parsoid\\Fixer' => __DIR__ . '/includes/Parsoid/Fixer.php', 'Flow\\Parsoid\\Fixer\\BadImageRemover' => __DIR__ . '/includes/Parsoid/Fixer/BadImageRemover.php', 'Flow\\Parsoid\\Fixer\\BaseHrefFixer' => __DIR__ . '/includes/Parsoid/Fixer/BaseHrefFixer.php', - 'Flow\\Parsoid\\Fixer\\Redlinker' => __DIR__ . '/includes/Parsoid/Fixer/Redlinker.php', + 'Flow\\Parsoid\\Fixer\\WikiLinkFixer' => __DIR__ . '/includes/Parsoid/Fixer/WikiLinkFixer.php', 'Flow\\Parsoid\\ReferenceExtractor' => __DIR__ . '/includes/Parsoid/ReferenceExtractor.php', 'Flow\\Parsoid\\ReferenceFactory' => __DIR__ . '/includes/Parsoid/ReferenceFactory.php', 'Flow\\Parsoid\\Utils' => __DIR__ . '/includes/Parsoid/Utils.php', @@ -343,8 +343,8 @@ 'Flow\\Tests\\NotifiedUsersTest' => __DIR__ . '/tests/phpunit/Notifications/NotifiedUsersTest.php', 'Flow\\Tests\\PagerTest' => __DIR__ . '/tests/phpunit/PagerTest.php', 'Flow\\Tests\\Parsoid\\BadImageRemoverTest' => __DIR__ . '/tests/phpunit/Parsoid/Fixer/BadImageRemoverTest.php', - 'Flow\\Tests\\Parsoid\\Fixer\\MethodReturnsConstraint' => __DIR__ . '/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php', - 'Flow\\Tests\\Parsoid\\Fixer\\RedlinkerTest' => __DIR__ . '/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php', + 'Flow\\Tests\\Parsoid\\Fixer\\MethodReturnsConstraint' => __DIR__ . '/tests/phpunit/Parsoid/Fixer/WikiLinkFixerTest.php', + 'Flow\\Tests\\Parsoid\\Fixer\\WikiLinkFixerTest' => __DIR__ . '/tests/phpunit/Parsoid/Fixer/WikiLinkFixerTest.php', 'Flow\\Tests\\Parsoid\\ParsoidUtilsTest' => __DIR__ . '/tests/phpunit/Parsoid/UtilsTest.php', 'Flow\\Tests\\Parsoid\\ReferenceExtractorTestCase' => __DIR__ . '/tests/phpunit/Parsoid/ReferenceExtractorTest.php', 'Flow\\Tests\\Parsoid\\ReferenceFactoryTest' => __DIR__ . '/tests/phpunit/Parsoid/ReferenceFactoryTest.php', diff --git a/container.php b/container.php index 176e9d8..46f3a07 100644 --- a/container.php +++ b/container.php @@ -64,8 +64,8 @@ return new LinkBatch; }; -$c['redlinker'] = function( $c ) { - return new Flow\Parsoid\Fixer\Redlinker( $c['link_batch'] ); +$c['wiki_link_fixer'] = function( $c ) { + return new Flow\Parsoid\Fixer\WikiLinkFixer( $c['link_batch'] ); }; $c['bad_image_remover'] = function( $c ) { @@ -80,7 +80,7 @@ $c['content_fixer'] = function( $c ) { return new Flow\Parsoid\ContentFixer( - $c['redlinker'], + $c['wiki_link_fixer'], $c['bad_image_remover'], $c['base_href_fixer'] ); diff --git a/includes/Parsoid/Fixer/BaseHrefFixer.php b/includes/Parsoid/Fixer/BaseHrefFixer.php index 9621f09..86b8e27 100644 --- a/includes/Parsoid/Fixer/BaseHrefFixer.php +++ b/includes/Parsoid/Fixer/BaseHrefFixer.php @@ -11,7 +11,7 @@ * * For now, we just apply this transformation to our own user * Parsoid content. It does not need to be done for WikiLink, since - * that is handled by Redlinker in another way. + * that is handled by WikiLinkFixer in another way. */ class BaseHrefFixer implements Fixer { /** @@ -33,7 +33,7 @@ * @return string XPath of elements this acts on */ public function getXPath() { - // Redlinker handles mw:WikiLink + // WikiLinkFixer handles mw:WikiLink return '//a[@href and not(@rel="mw:WikiLink")]'; } diff --git a/includes/Parsoid/Fixer/Redlinker.php b/includes/Parsoid/Fixer/WikiLinkFixer.php similarity index 86% rename from includes/Parsoid/Fixer/Redlinker.php rename to includes/Parsoid/Fixer/WikiLinkFixer.php index c181423..5fa3139 100644 --- a/includes/Parsoid/Fixer/Redlinker.php +++ b/includes/Parsoid/Fixer/WikiLinkFixer.php @@ -14,27 +14,24 @@ /** * Parsoid ignores red links. With good reason: redlinks should only be - * applied when rendering the content, not when it's created. This - * class updates HTML content from Parsoid with anchors generated by - * Linker::link. + * applied when rendering the content, not when it's created. + * + * This class updates HTML content from Parsoid with anchors generated by + * Linker::link. In addition to handling red links, this normalizes + * relative paths to start with a /, so the HTML renders correctly + * on any page. */ -class Redlinker implements Fixer { +class WikiLinkFixer implements Fixer { /** * @var LinkBatch */ protected $batch; /** - * @var ArrayObject - */ - protected $processed; - - /** * @param LinkBatch $batch */ public function __construct( LinkBatch $batch ) { $this->batch = $batch; - $this->processed = new ArrayObject; } /** diff --git a/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php b/tests/phpunit/Parsoid/Fixer/WikiLinkFixerTest.php similarity index 94% rename from tests/phpunit/Parsoid/Fixer/RedlinkerTest.php rename to tests/phpunit/Parsoid/Fixer/WikiLinkFixerTest.php index e31a6d4..308d8b2 100644 --- a/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php +++ b/tests/phpunit/Parsoid/Fixer/WikiLinkFixerTest.php @@ -4,7 +4,7 @@ use Flow\Model\UUID; use Flow\Parsoid\ContentFixer; -use Flow\Parsoid\Fixer\Redlinker; +use Flow\Parsoid\Fixer\WikiLinkFixer; use Flow\Parsoid\Utils; use Flow\Tests\PostRevisionTestCase; use Html; @@ -13,7 +13,7 @@ /** * @group Flow */ -class RedlinkerTest extends PostRevisionTestCase { +class WikiLinkFixerTest extends PostRevisionTestCase { static public function redLinkProvider() { return array( @@ -67,7 +67,7 @@ * @dataProvider redLinkProvider */ public function testAppliesRedLinks( $message, $anchor, $expect ) { - $fixer = new ContentFixer( new Redlinker( $this->getMock( 'LinkBatch' ) ) ); + $fixer = new ContentFixer( new WikiLinkFixer( $this->getMock( 'LinkBatch' ) ) ); $result = $fixer->apply( $anchor, Title::newMainPage() ); $this->assertContains( $expect, $result, $message ); } -- To view, visit https://gerrit.wikimedia.org/r/196493 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia3561e085b5b5fd6e739c5a4fe6a8ff576c26e70 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: SG <shah...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits