jenkins-bot has submitted this change and it was merged.

Change subject: Make PPFrame::RECOVER_COMMENTS actually work
......................................................................


Make PPFrame::RECOVER_COMMENTS actually work

Because of a missing condition, it generally only had an effect on
output type Parser::OT_WIKI, and thus {{msgnw:}} would strip comments
except when substituted during a pre-save transform.

Bug: T98841
Change-Id: I1e47696434fe87475f9902e6bfb8990566456e2f
---
M RELEASE-NOTES-1.26
M includes/parser/Preprocessor_DOM.php
M includes/parser/Preprocessor_Hash.php
M tests/parser/parserTests.txt
4 files changed, 9 insertions(+), 2 deletions(-)

Approvals:
  TTO: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26
index 73691b1..3442ee0 100644
--- a/RELEASE-NOTES-1.26
+++ b/RELEASE-NOTES-1.26
@@ -73,6 +73,7 @@
 === Bug fixes in 1.26 ===
 * (T53283) load.php sometimes sends 304 response without full headers
 * (T65198) Talk page tabs now have a "rel=discussion" attribute
+* (T98841) {{msgnw:}} now preserves comments even when subst: is not used.
 
 === Action API changes in 1.26 ===
 * New-style continuation is now the default for action=continue. Clients may
diff --git a/includes/parser/Preprocessor_DOM.php 
b/includes/parser/Preprocessor_DOM.php
index 718ca35..8a09be8 100644
--- a/includes/parser/Preprocessor_DOM.php
+++ b/includes/parser/Preprocessor_DOM.php
@@ -1203,9 +1203,11 @@
                                } elseif ( $contextNode->nodeName == 'comment' 
) {
                                        # HTML-style comment
                                        # Remove it in HTML, pre+remove and 
STRIP_COMMENTS modes
-                                       if ( $this->parser->ot['html']
+                                       # Not in RECOVER_COMMENTS mode (msgnw) 
though.
+                                       if ( ( $this->parser->ot['html']
                                                || ( $this->parser->ot['pre'] 
&& $this->parser->mOptions->getRemoveComments() )
                                                || ( $flags & 
PPFrame::STRIP_COMMENTS )
+                                               ) && !( $flags & 
PPFrame::RECOVER_COMMENTS )
                                        ) {
                                                $out .= '';
                                        } elseif ( $this->parser->ot['wiki'] && 
!( $flags & PPFrame::RECOVER_COMMENTS ) ) {
diff --git a/includes/parser/Preprocessor_Hash.php 
b/includes/parser/Preprocessor_Hash.php
index d1ad39c..8ddb401 100644
--- a/includes/parser/Preprocessor_Hash.php
+++ b/includes/parser/Preprocessor_Hash.php
@@ -1124,9 +1124,11 @@
                                } elseif ( $contextNode->name == 'comment' ) {
                                        # HTML-style comment
                                        # Remove it in HTML, pre+remove and 
STRIP_COMMENTS modes
-                                       if ( $this->parser->ot['html']
+                                       # Not in RECOVER_COMMENTS mode (msgnw) 
though.
+                                       if ( ( $this->parser->ot['html']
                                                || ( $this->parser->ot['pre'] 
&& $this->parser->mOptions->getRemoveComments() )
                                                || ( $flags & 
PPFrame::STRIP_COMMENTS )
+                                               ) && !( $flags & 
PPFrame::RECOVER_COMMENTS )
                                        ) {
                                                $out .= '';
                                        } elseif ( $this->parser->ot['wiki'] && 
!( $flags & PPFrame::RECOVER_COMMENTS ) ) {
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 2e1806d..1d331df 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -10321,6 +10321,7 @@
 <gallery>
 File:Foobar.jpg
 </gallery>
+<!-- comment -->
 !! endarticle
 
 # hmm, fix this or just deprecate msgnw and document its behavior?
@@ -10336,6 +10337,7 @@
 &#60;gallery&#62;
 File:Foobar.jpg
 &#60;/gallery&#62;
+&#60;!-- comment --&#62;
 </p>
 !! end
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e47696434fe87475f9902e6bfb8990566456e2f
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: PleaseStand <[email protected]>
Gerrit-Reviewer: TTO <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to