From 8b0e7298ac25ccbb83d382bcb81f6c9433d053ca Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 22 Dec 2017 13:47:33 -0500 Subject: [PATCH] Remove wrapclass from parser cache key This will result in an exception from WikiPage::getParserOutput() if anything was missed. This also hard-deprecates ParserOptions::setWrapOutputClass( false ) Bug: T181846 Change-Id: Ica541e1f6b52f5eec6d28cff60ba64bf525258c7 Depends-On: Ie5d6c5ce34c05b8fe2353d3bb36b2a3a4166ec4b Depends-On: Ibfaefde2f3811151ec712554cbc9cf2415ed017f Depends-On: I55048bbae5d4d2d0c79c241c1784448b82db3bb4 Depends-On: I23a26ba0dfbe83007cd40e97d71a2139a5ecddc7 Depends-On: Ibc013a41f4a463f4014fbbce7ce27f8690161728 Depends-On: Ie936dff918dc0869503a924298b4580402038b52 --- RELEASE-NOTES-1.31 | 3 +++ includes/parser/ParserOptions.php | 8 +++++--- tests/phpunit/includes/parser/ParserOptionsTest.php | 8 +++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index ad24852e73..20bea0bd2a 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -196,6 +196,9 @@ changes to languages because of Phabricator reports. used for that. Rather, setRef() existed as memory optimisation for PHP 4. * Passing false to ParserOptions::setWrapOutputClass() is deprecated. Use the 'unwrap' transform to ParserOutput::getText() instead. +* ParserOutput objects generated using a non-default value for + ParserOptions::setWrapOutputClass() can no longer be added to the parser + cache. == Compatibility == MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is supported, diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 1405c451e3..ca8e739f9a 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -65,7 +65,6 @@ class ParserOptions { 'stubthreshold' => true, 'printable' => true, 'userlang' => true, - 'wrapclass' => true, ]; /** @@ -780,14 +779,17 @@ class ParserOptions { /** * CSS class to use to wrap output from Parser::parse() * @since 1.30 - * @param string|bool $className Set false to disable wrapping. - * Passing false is deprecated since MediaWiki 1.31 + * @param string $className Class name to use for wrapping. + * Passing false to indicate "no wrapping" was deprecated in MediaWiki 1.31. * @return string|bool Current value */ public function setWrapOutputClass( $className ) { if ( $className === true ) { // DWIM, they probably want the default class name $className = 'mw-parser-output'; } + if ( $className === false ) { + wfDeprecated( __METHOD__ . '( false )', '1.31' ); + } return $this->setOption( 'wrapclass', $className ); } diff --git a/tests/phpunit/includes/parser/ParserOptionsTest.php b/tests/phpunit/includes/parser/ParserOptionsTest.php index 232b0bb141..d55372c61f 100644 --- a/tests/phpunit/includes/parser/ParserOptionsTest.php +++ b/tests/phpunit/includes/parser/ParserOptionsTest.php @@ -21,7 +21,6 @@ class ParserOptionsTest extends MediaWikiTestCase { 'stubthreshold' => true, 'printable' => true, 'userlang' => true, - 'wrapclass' => true, ]; } @@ -67,6 +66,9 @@ class ParserOptionsTest extends MediaWikiTestCase { 'Non-in-key options are not ok' => [ false, [ 'removeComments' => false, ] ], + 'Non-in-key options are not ok (2)' => [ false, [ + 'wrapclass' => 'foobar', + ] ], 'Canonical override, not default (1)' => [ true, [ 'tidy' => true, ] ], @@ -213,7 +215,7 @@ class ParserOptionsTest extends MediaWikiTestCase { $wgHooks['ParserOptionsRegister'] = []; $this->assertSame( [ 'dateformat', 'numberheadings', 'printable', 'stubthreshold', - 'thumbsize', 'userlang', 'wrapclass', + 'thumbsize', 'userlang' ], ParserOptions::allCacheVaryingOptions() ); self::clearCache(); @@ -231,7 +233,7 @@ class ParserOptionsTest extends MediaWikiTestCase { }; $this->assertSame( [ 'dateformat', 'foo', 'numberheadings', 'printable', 'stubthreshold', - 'thumbsize', 'userlang', 'wrapclass', + 'thumbsize', 'userlang' ], ParserOptions::allCacheVaryingOptions() ); } -- 2.20.1