jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404810 )
Change subject: Fix regressions with updated lead intro transform ...................................................................... Fix regressions with updated lead intro transform This is a combination of 2 commits: 1) Avoid notice in lead paragraph transform when encounter infobox like elements XPath query can return tables that look like infoboxes as contains(@class,"infobox") is not the same as hasClass('infobox'). Thus getInfoboxContainer can resolve to false. This test and fix guards against that. Bug: T185106 Change-Id: I5a8fbbb956365de9af09ee8d238fb3389e8f2cef 2) Remove blacklisted content before applying transforms Previously we removed all blacklisted elements AFTER applying transforms such as moving lead paragraph. This is unnecessary and can lead to problems, for example infoboxes inside elements which are to be removed, might be moved above the lead paragraph and skip the blacklisting altogether. This also leads to unnecessary logging when the move is not possible. HtmlFormatter::filterContent takes care of content removal so lets do that BEFORE our transformations explicitly. Bug: T185040 Change-Id: I18bc97fa37bdc53e61cb6de79fb6bc1158ffd9fe --- M includes/MobileFormatter.php M includes/transforms/MoveLeadParagraphTransform.php M tests/phpunit/transforms/MoveLeadParagraphTransformTest.php 3 files changed, 8 insertions(+), 3 deletions(-) Approvals: 20after4: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php index 55429ba..0774271 100644 --- a/includes/MobileFormatter.php +++ b/includes/MobileFormatter.php @@ -183,6 +183,8 @@ $this->doRemoveImages(); } + // Apply all removals before continuing with transforms (see T185040 for example) + $removed = parent::filterContent(); $transformOptions = [ 'images' => $removeImages, 'references' => $removeReferences, @@ -200,8 +202,7 @@ if ( $transformOptions['references'] ) { $this->doRewriteReferencesLinksForLazyLoading( $doc ); } - - return parent::filterContent(); + return $removed; } /** diff --git a/includes/transforms/MoveLeadParagraphTransform.php b/includes/transforms/MoveLeadParagraphTransform.php index d2d5b35..08ef454 100644 --- a/includes/transforms/MoveLeadParagraphTransform.php +++ b/includes/transforms/MoveLeadParagraphTransform.php @@ -107,7 +107,7 @@ if ( $listElementAfterParagraph !== null ) { $leadSectionBody->insertBefore( $listElementAfterParagraph, $where ); } - } elseif ( $infobox->parentNode !== $leadSectionBody ) { + } elseif ( $infobox && $infobox->parentNode !== $leadSectionBody ) { /** * @see https://phabricator.wikimedia.org/T149884 * @todo remove after research is done diff --git a/tests/phpunit/transforms/MoveLeadParagraphTransformTest.php b/tests/phpunit/transforms/MoveLeadParagraphTransformTest.php index c2cbc2c..bfd8dc7 100644 --- a/tests/phpunit/transforms/MoveLeadParagraphTransformTest.php +++ b/tests/phpunit/transforms/MoveLeadParagraphTransformTest.php @@ -91,6 +91,10 @@ return [ [ + '<div><table class="mf-infobox"></table></div><p>one</p>', + '<div><table class="mf-infobox"></table></div><p>one</p>' + ], + [ "$infobox$paragraph", "$paragraph$infobox", ], -- To view, visit https://gerrit.wikimedia.org/r/404810 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I18bc97fa37bdc53e61cb6de79fb6bc1158ffd9fe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: wmf/1.31.0-wmf.16 Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: 20after4 <mmod...@wikimedia.org> Gerrit-Reviewer: Pmiazga <pmia...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits