EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/195588
Change subject: Handle multiple parts in TransclusionExtractor
......................................................................
Handle multiple parts in TransclusionExtractor
The transclusion can be any part not just the first. Loop through
and figure out where the transclusion is.
Change-Id: I17508dd6362bc4b0d0207984652e4e887d1e4f0e
---
M includes/Parsoid/Extractor/TransclusionExtractor.php
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/88/195588/1
diff --git a/includes/Parsoid/Extractor/TransclusionExtractor.php
b/includes/Parsoid/Extractor/TransclusionExtractor.php
index 7c064bc..771be95 100644
--- a/includes/Parsoid/Extractor/TransclusionExtractor.php
+++ b/includes/Parsoid/Extractor/TransclusionExtractor.php
@@ -24,11 +24,22 @@
* {@inheritDoc}
*/
public function perform( ReferenceFactory $factory, DOMElement $element
) {
- $data = FormatJson::decode( $element->getAttribute( 'data-mw' )
);
- $templateTarget = Title::newFromText(
- $data->parts[0]->template->target->wt,
- NS_TEMPLATE
- );
+ $orig = $element->getAttribute( 'data-mw' );
+ $data = FormatJson::decode( $orig );
+ if ( !isset( $data->parts ) || !is_array( $data->parts ) ) {
+ throw new \Exception( "Missing template target: $orig"
);
+ }
+ $target = null;
+ foreach ( $data->parts as $part ) {
+ if ( isset( $part->template->target->wt ) ) {
+ $target = $part->template->target->wt;
+ break;
+ }
+ }
+ if ( $target === null ) {
+ throw new \Exception( "Missing template target: $orig"
);
+ }
+ $templateTarget = Title::newFromText( $target, NS_TEMPLATE );
if ( !$templateTarget ) {
return null;
--
To view, visit https://gerrit.wikimedia.org/r/195588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17508dd6362bc4b0d0207984652e4e887d1e4f0e
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