From c8e482371407477ecd4f0a1b5778e565d3963a93 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 22 Nov 2017 18:11:43 -0500 Subject: [PATCH 1/1] Warn if stateful ParserOutput transforms are used This should help clean up any missed uses. Change-Id: I371f3b27d245d6927c74ea52f1df9fd5c675b94a Depends-On: I30f162aa43c7f513df1153e0884a4339e4279aeb Depends-On: Iff28b00638c15de7307a130196bbb91cda91c3d1 Depends-On: I432da8c0686c279b3c2e770f7f9e20248589d6db Depends-On: I404f064b93573e80b61a228e3cf2b5d2add65c39 Depends-On: Ia54a9e3d11c9ab28975947148d0841819f3a8e3c Depends-On: I2cd7519186f2319f32cf6288655ddb873337a638 Depends-On: I28b46cf4da66cc6e1f04045939a243faa30bc9bf Depends-On: I3565868af824a08235ab5ce4a34145895ed0e74d Depends-On: I0d05ce2f565778a4bf39d3d25d26acd0b8043788 Depends-On: I100fae755ae7e729d11163377fbddaebeaa020a6 Depends-On: I38e56d04f7ffbe8796dbda6500106a028a459980 Depends-On: Id6ad08a0b1f8575e7ee98916217a84c09e72dd3b Depends-On: I2794430f6bc076f073e79e662701403f7e063c35 Depends-On: I39b599246759baad2164a29244150c99f0920684 Depends-On: Ic7aa606b7d697e06c74c1e9207efc77442f5b0c3 Depends-On: I140ff32373430b61b92226689ef9b58cca317450 Depends-On: I9b082e37f19c8baa182b0583c7d70d692fafc16e --- includes/parser/ParserOutput.php | 9 ++++++--- tests/phpunit/includes/parser/ParserOutputTest.php | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index ff9c28d2bb..be574f0033 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -271,13 +271,16 @@ class ParserOutput extends CacheTime { * @return string HTML */ public function getText( $options = [] ) { - // @todo Warn if !array_key_exists( 'allowTOC', $options ) && empty( $this->mTOCEnabled ) + if ( !array_key_exists( 'allowTOC', $options ) && empty( $this->mTOCEnabled ) ) { + wfDeprecated( 'ParserOutput stateful allowTOC', '1.31' ); + } - // @todo Warn if !array_key_exists( 'enableSectionEditLinks', $options ) - // && !$this->mEditSectionTokens // Note that while $this->mEditSectionTokens formerly defaulted to false, // ParserOptions->getEditSection() defaults to true and Parser copies // that to us so true makes more sense as the stateless default. + if ( !array_key_exists( 'enableSectionEditLinks', $options ) && !$this->mEditSectionTokens ) { + wfDeprecated( 'ParserOutput stateful enableSectionEditLinks', '1.31' ); + } $options += [ // empty() here because old cached versions might lack the field somehow. diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php index 441d60df7b..6854a274f1 100644 --- a/tests/phpunit/includes/parser/ParserOutputTest.php +++ b/tests/phpunit/includes/parser/ParserOutputTest.php @@ -105,6 +105,8 @@ class ParserOutputTest extends MediaWikiTestCase { 'wgScriptPath' => '/w', 'wgScript' => '/w/index.php', ] ); + $this->hideDeprecated( 'ParserOutput stateful allowTOC' ); + $this->hideDeprecated( 'ParserOutput stateful enableSectionEditLinks' ); $po = new ParserOutput( $text ); -- 2.20.1