X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FParserOptions.php;h=96a43682585061a3327b7e5dce47af14e77d41dd;hb=cc0d030a96f9635a7da24cd3e6c42177a3bd100d;hp=5be0321bbeb854ab105738a4bd88d8845be248bb;hpb=3bf87f39002e58f0240ef8676efc5b3280287c53;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 5be0321bbe..96a4368258 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -1211,10 +1211,11 @@ class ParserOptions { * Returns the full array of options that would have been used by * in 1.16. * Used to get the old parser cache entries when available. - * @todo 1.16 was years ago, can we remove this? + * @deprecated since 1.30. You probably want self::allCacheVaryingOptions() instead. * @return array */ public static function legacyOptions() { + wfDeprecated( __METHOD__, '1.30' ); return [ 'stubthreshold', 'numberheadings', @@ -1225,6 +1226,20 @@ class ParserOptions { ]; } + /** + * Return all option keys that vary the options hash + * @since 1.30 + * @return string[] + */ + public static function allCacheVaryingOptions() { + // Trigger a call to the 'ParserOptionsRegister' hook if it hasn't + // already been called. + if ( self::$defaults === null ) { + self::getDefaults(); + } + return array_keys( array_filter( self::$inCacheKey ) ); + } + /** * Convert an option to a string value * @param mixed $value @@ -1269,8 +1284,7 @@ class ParserOptions { // Feb 2015 (instead the parser outputs a constant placeholder and post-parse // processing handles the option). But Wikibase forces it in $forOptions // and expects the cache key to still vary on it for T85252. - // @todo Deprecate and remove this behavior after optionsHashPre30() is - // removed (Wikibase can use addExtraKey() or something instead). + // @deprecated since 1.30, Wikibase should use addExtraKey() or something instead. if ( in_array( 'editsection', $forOptions, true ) ) { $options['editsection'] = $this->mEditSection; $defaults['editsection'] = true; @@ -1321,98 +1335,6 @@ class ParserOptions { return $confstr; } - /** - * Generate the hash used before MediaWiki 1.30 - * @since 1.30 - * @deprecated since 1.30. Do not use this unless you're ParserCache. - * @param array $forOptions - * @param Title $title Used to get the content language of the page (since r97636) - * @return string Page rendering hash - */ - public function optionsHashPre30( $forOptions, $title = null ) { - global $wgRenderHashAppend; - - // 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 - // be 0 when this function is called by parsercache. - if ( in_array( 'stubthreshold', $forOptions ) ) { - $confstr .= '!' . $this->options['stubthreshold']; - } else { - $confstr .= '!*'; - } - - if ( in_array( 'dateformat', $forOptions ) ) { - $confstr .= '!' . $this->getDateFormat(); - } - - if ( in_array( 'numberheadings', $forOptions ) ) { - $confstr .= '!' . ( $this->options['numberheadings'] ? '1' : '' ); - } else { - $confstr .= '!*'; - } - - if ( in_array( 'userlang', $forOptions ) ) { - $confstr .= '!' . $this->options['userlang']->getCode(); - } else { - $confstr .= '!*'; - } - - if ( in_array( 'thumbsize', $forOptions ) ) { - $confstr .= '!' . $this->options['thumbsize']; - } else { - $confstr .= '!*'; - } - - // add in language specific options, if any - // @todo FIXME: This is just a way of retrieving the url/user preferred variant - if ( !is_null( $title ) ) { - $confstr .= $title->getPageLanguage()->getExtraHashOptions(); - } else { - global $wgContLang; - $confstr .= $wgContLang->getExtraHashOptions(); - } - - $confstr .= $wgRenderHashAppend; - - // @note: as of Feb 2015, core never sets the editsection flag, since it uses - // tags to inject editsections on the fly. However, extensions - // may be using it by calling ParserOption::optionUsed resp. ParserOutput::registerOption - // directly. At least Wikibase does at this point in time. - if ( !in_array( 'editsection', $forOptions ) ) { - $confstr .= '!*'; - } elseif ( !$this->mEditSection ) { - $confstr .= '!edit=0'; - } - - if ( $this->options['printable'] && in_array( 'printable', $forOptions ) ) { - $confstr .= '!printable=1'; - } - - if ( $this->options['wrapclass'] !== 'mw-parser-output' && - in_array( 'wrapclass', $forOptions ) - ) { - $confstr .= '!wrapclass=' . $this->options['wrapclass']; - } - - if ( $this->mExtraKey != '' ) { - $confstr .= $this->mExtraKey; - } - - // Give a chance for extensions to modify the hash, if they have - // extra options or other effects on the parser cache. - Hooks::run( 'PageRenderingHash', [ &$confstr, $this->getUser(), &$forOptions ] ); - - // Make it a valid memcached key fragment - $confstr = str_replace( ' ', '_', $confstr ); - - return $confstr; - } - /** * Test whether these options are safe to cache * @since 1.30