PleaseStand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/210677
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 (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, 10 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/77/210677/1
diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26
index 3d6651f..050a557 100644
--- a/RELEASE-NOTES-1.26
+++ b/RELEASE-NOTES-1.26
@@ -20,6 +20,8 @@
=== Bug fixes in 1.26 ===
* (bug 51283) load.php sometimes sends 304 response without full headers
+* (T98841) {{msgnw:}} will correctly recover the original code of comments
+ even when it is not substituted as part of a pre-save transform.
=== Action API changes in 1.26 ===
* API action=query&list=tags: The displayname can now be boolean false if the
diff --git a/includes/parser/Preprocessor_DOM.php
b/includes/parser/Preprocessor_DOM.php
index 0351f2a..bbf7aa1 100644
--- a/includes/parser/Preprocessor_DOM.php
+++ b/includes/parser/Preprocessor_DOM.php
@@ -1195,15 +1195,16 @@
} 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
(extractSections, 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 ) ) {
# Add a strip marker in PST
mode so that pstPass2() can
# run some old-fashioned
regexes on the result.
- # Not in RECOVER_COMMENTS mode
(extractSections) though.
$out .=
$this->parser->insertStripItem( $contextNode->textContent );
} else {
# Recover the literal comment
in RECOVER_COMMENTS and pre+no-remove
diff --git a/includes/parser/Preprocessor_Hash.php
b/includes/parser/Preprocessor_Hash.php
index af91ad4..26b524d 100644
--- a/includes/parser/Preprocessor_Hash.php
+++ b/includes/parser/Preprocessor_Hash.php
@@ -1118,15 +1118,16 @@
} 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
(extractSections, 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 ) ) {
# Add a strip marker in PST
mode so that pstPass2() can
# run some old-fashioned
regexes on the result.
- # Not in RECOVER_COMMENTS mode
(extractSections) though.
$out .=
$this->parser->insertStripItem( $contextNode->firstChild->value );
} else {
# Recover the literal comment
in RECOVER_COMMENTS and pre+no-remove
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index e965352..48b4a7c 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -9892,6 +9892,7 @@
<gallery>
File:Foobar.jpg
</gallery>
+<!-- comment -->
!! endarticle
# hmm, fix this or just deprecate msgnw and document its behavior?
@@ -9907,6 +9908,7 @@
<gallery>
File:Foobar.jpg
</gallery>
+<!-- comment -->
</p>
!! end
--
To view, visit https://gerrit.wikimedia.org/r/210677
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e47696434fe87475f9902e6bfb8990566456e2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits