From 20cbd0f226a1575db3f3397de10a8daf0d0ad8d2 Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Wed, 13 May 2015 07:54:12 -0400 Subject: [PATCH] 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 --- RELEASE-NOTES-1.26 | 1 + includes/parser/Preprocessor_DOM.php | 4 +++- includes/parser/Preprocessor_Hash.php | 4 +++- tests/parser/parserTests.txt | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 73691b1afa..3442ee0ed9 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -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 diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 718ca35afb..8a09be839c 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -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 ) ) { diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index d1ad39c55c..8ddb401f7a 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -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 ) ) { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 2e1806da58..1d331dff50 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -10321,6 +10321,7 @@ Template:MSGNW test File:Foobar.jpg + !! endarticle # hmm, fix this or just deprecate msgnw and document its behavior? @@ -10336,6 +10337,7 @@ msgnw keyword <gallery> File:Foobar.jpg </gallery> +<!-- comment -->

!! end -- 2.20.1