EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/191787

Change subject: Update Image and Placeholder extraction routines
......................................................................

Update Image and Placeholder extraction routines

It seems that at one point the tests for this started failing, we didn't notice
because these tests don't run inside jenkins due to the parsoid requirement.

A followup patch fixes so jenkins will run these tests as expected.

Change-Id: I43add6424e564b477be752193254471c52a44e6d
---
M includes/Parsoid/Extractor/ImageExtractor.php
M includes/Parsoid/Extractor/PlaceholderExtractor.php
M tests/phpunit/Parsoid/ReferenceExtractorTest.php
3 files changed, 7 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/87/191787/1

diff --git a/includes/Parsoid/Extractor/ImageExtractor.php 
b/includes/Parsoid/Extractor/ImageExtractor.php
index edf2dff..e071e8f 100644
--- a/includes/Parsoid/Extractor/ImageExtractor.php
+++ b/includes/Parsoid/Extractor/ImageExtractor.php
@@ -6,6 +6,7 @@
 use Flow\Model\WikiReference;
 use Flow\Parsoid\Extractor;
 use Flow\Parsoid\ReferenceFactory;
+use Flow\Utils\DOMNodeRecursiveIterator;
 
 /**
  * Finds and creates References for images in parsoid HTML
@@ -15,7 +16,7 @@
         * {@inheritDoc}
         */
        public function getXPath() {
-               return '//*[starts-with(@typeof, "mw:Image")]';
+               return '//*[contains(concat(" ", @typeof, " "), " mw:Image " 
)]';
        }
 
        /**
@@ -30,7 +31,7 @@
                        if ( $resource !== '' ) {
                                return $factory->createWikiReference(
                                        WikiReference::TYPE_FILE,
-                                       $resource
+                                       urldecode( $resource )
                                );
                        }
                }
diff --git a/includes/Parsoid/Extractor/PlaceholderExtractor.php 
b/includes/Parsoid/Extractor/PlaceholderExtractor.php
index bdd7eda..4022979 100644
--- a/includes/Parsoid/Extractor/PlaceholderExtractor.php
+++ b/includes/Parsoid/Extractor/PlaceholderExtractor.php
@@ -24,7 +24,7 @@
         * {@inheritDoc}
         */
        public function getXPath() {
-               return '//*[starts-with(@typeof, "mw:Placeholder")]';
+               return '//*[contains(concat(" ", @typeof, " "), " 
mw:Placeholder" )]';
        }
 
        /**
diff --git a/tests/phpunit/Parsoid/ReferenceExtractorTest.php 
b/tests/phpunit/Parsoid/ReferenceExtractorTest.php
index e47e85c..b7af650 100644
--- a/tests/phpunit/Parsoid/ReferenceExtractorTest.php
+++ b/tests/phpunit/Parsoid/ReferenceExtractorTest.php
@@ -163,13 +163,14 @@
                $reflProperty->setAccessible( true );
                $extractors = $reflProperty->getValue( $referenceExtractor );
 
+               $html = Utils::convert( 'wt', 'html', $wikitext, 
Title::newFromText( $page ) );
                $result = $reflMethod->invoke(
                        $referenceExtractor,
                        $factory,
                        $extractors['post'],
-                       Utils::convert( 'wt', 'html', $wikitext, 
Title::newFromText( $page ) )
+                       $html
                );
-               $this->assertCount( 1, $result );
+               $this->assertCount( 1, $result, $html );
 
                $result = reset( $result );
                $this->assertInstanceOf( $expectedClass, $result, $description 
);

-- 
To view, visit https://gerrit.wikimedia.org/r/191787
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43add6424e564b477be752193254471c52a44e6d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to