Disable expensive {{REVISIONID}} magic word in miser mode
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 16 Jun 2016 20:01:38 +0000 (13:01 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 9 Mar 2019 18:50:49 +0000 (10:50 -0800)
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

index 0fe456d..b0c4bf9 100644 (file)
@@ -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 ) {