From dca260fb302153db4eaec78a7f6e148a12e0561b Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Mon, 20 Jan 2014 09:00:54 +0000 Subject: [PATCH] Remove math specific code from ParserOptions There is some math specific code in ParserOptions. To allow extensions like math to change the cache key in a reasonable matter, they need to get access to the information which options were used. Therefore, optionUsed is public now and the additional argument $forOptions was added to the PageRenderingHash hook. Bug: 60234 Change-Id: Ieecb27216c39b7e6e354b4a1904fbff06506307d --- includes/parser/ParserOptions.php | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 2ab1d89842..7c6dde6b9f 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -164,11 +164,6 @@ class ParserOptions { */ var $mNumberHeadings; - /** - * User math preference (as integer). Not used (1.19) - */ - var $mMath; - /** * Thumb size preferred by the user. */ @@ -240,9 +235,6 @@ class ParserOptions { function getExternalLinkTarget() { return $this->mExternalLinkTarget; } function getDisableContentConversion() { return $this->mDisableContentConversion; } function getDisableTitleConversion() { return $this->mDisableTitleConversion; } - /** @deprecated since 1.22 use User::getOption('math') instead */ - function getMath() { $this->optionUsed( 'math' ); - return $this->mMath; } function getThumbSize() { $this->optionUsed( 'thumbsize' ); return $this->mThumbSize; } function getStubThreshold() { $this->optionUsed( 'stubthreshold' ); @@ -329,8 +321,6 @@ class ParserOptions { function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); } function disableContentConversion( $x = true ) { return wfSetVar( $this->mDisableContentConversion, $x ); } function disableTitleConversion( $x = true ) { return wfSetVar( $this->mDisableTitleConversion, $x ); } - /** @deprecated since 1.22 */ - function setMath( $x ) { return wfSetVar( $this->mMath, $x ); } function setUserLang( $x ) { if ( is_string( $x ) ) { $x = Language::factory( $x ); @@ -441,7 +431,6 @@ class ParserOptions { $this->mUser = $user; $this->mNumberHeadings = $user->getOption( 'numberheadings' ); - $this->mMath = $user->getOption( 'math' ); $this->mThumbSize = $user->getOption( 'thumbsize' ); $this->mStubThreshold = $user->getStubThreshold(); $this->mUserLang = $lang; @@ -459,8 +448,9 @@ class ParserOptions { /** * Called when an option is accessed. + * @param string $optionName name of the option */ - protected function optionUsed( $optionName ) { + public function optionUsed( $optionName ) { if ( $this->onAccessCallback ) { call_user_func( $this->onAccessCallback, $optionName ); } @@ -473,7 +463,7 @@ class ParserOptions { * @return array */ public static function legacyOptions() { - return array( 'math', 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' ); + return array( 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' ); } /** @@ -495,13 +485,10 @@ class ParserOptions { public function optionsHash( $forOptions, $title = null ) { global $wgRenderHashAppend; - $confstr = ''; - - if ( in_array( 'math', $forOptions ) ) { - $confstr .= $this->mMath; - } else { - $confstr .= '*'; - } + // FIXME: Once the cache key is reorganized this argument + // can be dropped. It was used when the math extension was + // part of core. + $confstr = '*'; // Space assigned for the stubthreshold but unused // since it disables the parser cache, its value will always @@ -561,7 +548,7 @@ class ParserOptions { // Give a chance for extensions to modify the hash, if they have // extra options or other effects on the parser cache. - wfRunHooks( 'PageRenderingHash', array( &$confstr, $this->getUser() ) ); + wfRunHooks( 'PageRenderingHash', array( &$confstr, $this->getUser(), &$forOptions ) ); // Make it a valid memcached key fragment $confstr = str_replace( ' ', '_', $confstr ); -- 2.20.1