From c537eb186862b38c2e5153fbfa300660f7896ac3 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 16 Jun 2016 13:01:38 -0700 Subject: [PATCH] Disable expensive {{REVISIONID}} magic word in miser mode This only applies to content namespaces for now since the cost of vary-revision-id is much less of a concern. The potential to harm page save time is far worse than what use they have, which is almost entirely just hacks to check for preview mode. These have nothing to do with the actual revision ID nor timestamp itself. They simply check whether the value is the empty string. Since this magic word still only returns an empty string in preview mode, such checks will keep working. Bug: T137900 Depends-on: I1809354055513a5b9d9589e2d6acda7579af76e2 Change-Id: Ieff8423ae3804b42d264f630e1a029199abf5976 --- includes/parser/Parser.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 0fe456df09..b0c4bf9c1a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2592,6 +2592,18 @@ class Parser { $ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() ); Hooks::run( 'ParserGetVariableValueTs', [ &$parser, &$ts ] ); + // In miser mode, disable words that always cause double-parses on page save (T137900) + static $slowRevWords = [ 'revisionid' => true ]; // @TODO: 'revisiontimestamp' + if ( + isset( $slowRevWords[$index] ) && + $this->siteConfig->get( 'MiserMode' ) && + !$this->mOptions->getInterfaceMessage() && + // @TODO: disallow this word on all namespaces + MWNamespace::isContent( $this->mTitle->getNamespace() ) + ) { + return $this->mRevisionId ? '-' : ''; + }; + $pageLang = $this->getFunctionLang(); switch ( $index ) { -- 2.20.1