Make PPFrame::RECOVER_COMMENTS actually work
authorKevin Israel <pleasestand@live.com>
Wed, 13 May 2015 11:54:12 +0000 (07:54 -0400)
committerKevin Israel <pleasestand@live.com>
Sat, 15 Aug 2015 08:12:23 +0000 (04:12 -0400)
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

RELEASE-NOTES-1.26
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
tests/parser/parserTests.txt

index 73691b1..3442ee0 100644 (file)
@@ -73,6 +73,7 @@ production.
 === 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
index 718ca35..8a09be8 100644 (file)
@@ -1203,9 +1203,11 @@ class PPFrame_DOM implements PPFrame {
                                } 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 ) ) {
index d1ad39c..8ddb401 100644 (file)
@@ -1124,9 +1124,11 @@ class PPFrame_Hash implements PPFrame {
                                } 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 ) ) {
index 2e1806d..1d331df 100644 (file)
@@ -10321,6 +10321,7 @@ Template:MSGNW test
 <gallery>
 File:Foobar.jpg
 </gallery>
+<!-- comment -->
 !! endarticle
 
 # hmm, fix this or just deprecate msgnw and document its behavior?
@@ -10336,6 +10337,7 @@ msgnw keyword
 &#60;gallery&#62;
 File:Foobar.jpg
 &#60;/gallery&#62;
+&#60;!-- comment --&#62;
 </p>
 !! end