aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@cscott.net>2019-04-09 14:42:42 -0400
committerC. Scott Ananian <cscott@cscott.net>2019-06-14 12:21:40 -0400
commit53fe91ded58c3be587a025984c7051c01be2fedc (patch)
tree748f3b19dd4ff172a4a42e1d9bd1e1c20cab984f
parent61544d6eb235342d004a2fefc159167f28c69099 (diff)
downloadmediawikicore-53fe91ded58c3be587a025984c7051c01be2fedc.tar.gz
mediawikicore-53fe91ded58c3be587a025984c7051c01be2fedc.zip
Hard deprecate Preprocessor_DOM
The Preprocessor_DOM implementation doesn't interact well with PHP memory profiling, and has some limitations not present in the Preprocessor_Hash implementation (see T216664). There is no reason to keep around two versions of the preprocessor: it just complicates on-going wikitext feature development. Hard deprecate use of Preprocessor_DOM, so we can remove the redundant code in a future release. Bug: T204945 Depends-On: Id38c9360e4d02b570996dbf7a660f964f02f1a2c Change-Id: Ica5d1ad5b1e677542962fc36d582a793f941155e
-rw-r--r--RELEASE-NOTES-1.343
-rw-r--r--includes/DefaultSettings.php3
-rw-r--r--includes/parser/PPCustomFrame_DOM.php1
-rw-r--r--includes/parser/PPFrame_DOM.php1
-rw-r--r--includes/parser/PPNode_DOM.php1
-rw-r--r--includes/parser/PPTemplateFrame_DOM.php1
-rw-r--r--includes/parser/Parser.php13
-rw-r--r--includes/parser/Preprocessor_DOM.php2
-rw-r--r--tests/parser/ParserTestRunner.php7
-rw-r--r--tests/phpunit/includes/parser/PreprocessorTest.php3
10 files changed, 23 insertions, 12 deletions
diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34
index cc1015c824c5..5917e3ce53bc 100644
--- a/RELEASE-NOTES-1.34
+++ b/RELEASE-NOTES-1.34
@@ -265,6 +265,9 @@ because of Phabricator reports.
* ResourceLoaderContext::getConfig and ResourceLoaderContext::getLogger have
been deprecated. Inside ResourceLoaderModule subclasses, use the local methods
instead. Elsewhere, use the methods from the ResourceLoader class.
+* The Preprocessor_DOM implementation has been deprecated. It will be
+ removed in a future release. Use the Preprocessor_Hash implementation
+ instead.
=== Other changes in 1.34 ===
* …
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 1be573d030f0..7d6318d2068e 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4153,6 +4153,9 @@ $wgInvalidRedirectTargets = [ 'Filepath', 'Mypage', 'Mytalk', 'Redirect' ];
* If this parameter is not given, it uses Preprocessor_DOM if the
* DOM module is available, otherwise it uses Preprocessor_Hash.
*
+ * The Preprocessor_DOM class is deprecated, and will be removed in a future
+ * release.
+ *
* The entire associative array will be passed through to the constructor as
* the first parameter. Note that only Setup.php can use this variable --
* the configuration will change at runtime via Parser member functions, so
diff --git a/includes/parser/PPCustomFrame_DOM.php b/includes/parser/PPCustomFrame_DOM.php
index 70663a0deaed..d274558afc0e 100644
--- a/includes/parser/PPCustomFrame_DOM.php
+++ b/includes/parser/PPCustomFrame_DOM.php
@@ -21,6 +21,7 @@
/**
* Expansion frame with custom arguments
+ * @deprecated since 1.34, use PPCustomFrame_Hash
* @ingroup Parser
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
diff --git a/includes/parser/PPFrame_DOM.php b/includes/parser/PPFrame_DOM.php
index a7fea0028aa9..03ee6d963963 100644
--- a/includes/parser/PPFrame_DOM.php
+++ b/includes/parser/PPFrame_DOM.php
@@ -21,6 +21,7 @@
/**
* An expansion frame, used as a context to expand the result of preprocessToObj()
+ * @deprecated since 1.34, use PPFrame_Hash
* @ingroup Parser
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
diff --git a/includes/parser/PPNode_DOM.php b/includes/parser/PPNode_DOM.php
index 8a435bab67a9..26a47911f335 100644
--- a/includes/parser/PPNode_DOM.php
+++ b/includes/parser/PPNode_DOM.php
@@ -20,6 +20,7 @@
*/
/**
+ * @deprecated since 1.34, use PPNode_Hash_{Tree,Text,Array,Attr}
* @ingroup Parser
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
diff --git a/includes/parser/PPTemplateFrame_DOM.php b/includes/parser/PPTemplateFrame_DOM.php
index 52cb9cb0f0b8..b4c874371d41 100644
--- a/includes/parser/PPTemplateFrame_DOM.php
+++ b/includes/parser/PPTemplateFrame_DOM.php
@@ -21,6 +21,7 @@
/**
* Expansion frame with template arguments
+ * @deprecated since 1.34, use PPTemplateFrame_Hash
* @ingroup Parser
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 486fdf441367..c61de38a867c 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -421,21 +421,10 @@ class Parser {
* Which class should we use for the preprocessor if not otherwise specified?
*
* @since 1.34
+ * @deprecated since 1.34, removing configurability of preprocessor
* @return string
*/
public static function getDefaultPreprocessorClass() {
- if ( wfIsHHVM() ) {
- # Under HHVM Preprocessor_Hash is much faster than Preprocessor_DOM
- return Preprocessor_Hash::class;
- }
- if ( extension_loaded( 'domxml' ) ) {
- # PECL extension that conflicts with the core DOM extension (T15770)
- wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" );
- return Preprocessor_Hash::class;
- }
- if ( extension_loaded( 'dom' ) ) {
- return Preprocessor_DOM::class;
- }
return Preprocessor_Hash::class;
}
diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php
index 0f0496beac15..9e510d21d64b 100644
--- a/includes/parser/Preprocessor_DOM.php
+++ b/includes/parser/Preprocessor_DOM.php
@@ -19,6 +19,7 @@
*
* @file
* @ingroup Parser
+ * @deprecated since 1.34, use Preprocessor_Hash
*/
/**
@@ -37,6 +38,7 @@ class Preprocessor_DOM extends Preprocessor {
const CACHE_PREFIX = 'preprocess-xml';
public function __construct( $parser ) {
+ wfDeprecated( __METHOD__, '1.34' ); // T204945
$this->parser = $parser;
$mem = ini_get( 'memory_limit' );
$this->memoryLimit = false;
diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php
index 3b63c19a94e8..7d46e834c147 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -797,6 +797,13 @@ class ParserTestRunner {
$class = $wgParserConf['class'];
$parser = new $class( [ 'preprocessorClass' => $preprocessor ] + $wgParserConf );
+ if ( $preprocessor ) {
+ # Suppress deprecation warning for Preprocessor_DOM while testing
+ Wikimedia\suppressWarnings();
+ wfDeprecated( 'Preprocessor_DOM::__construct' );
+ Wikimedia\restoreWarnings();
+ $parser->getPreprocessor();
+ }
ParserTestParserHook::setup( $parser );
return $parser;
diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php
index 6b3e05da513f..3b2b1050bd17 100644
--- a/tests/phpunit/includes/parser/PreprocessorTest.php
+++ b/tests/phpunit/includes/parser/PreprocessorTest.php
@@ -48,6 +48,9 @@ class PreprocessorTest extends MediaWikiTestCase {
$this->mOptions = ParserOptions::newFromUserAndLang( new User,
MediaWikiServices::getInstance()->getContentLanguage() );
+ # Suppress deprecation warning for Preprocessor_DOM while testing
+ $this->hideDeprecated( 'Preprocessor_DOM::__construct' );
+
$this->mPreprocessors = [];
foreach ( self::$classNames as $className ) {
$this->mPreprocessors[$className] = new $className( $this );