Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/294774

Change subject: [WIP] Disable expensive REVISION* magic words in miser mode
......................................................................

[WIP] Disable expensive REVISION* magic words in miser mode

The potential to tank page save time is worse than what little
use they have, which is mostly just hacks for things that have
nothing to do with the ID/timestamp itself.

Bug: T137900
Change-Id: Ieff8423ae3804b42d264f630e1a029199abf5976
---
M includes/parser/Parser.php
1 file changed, 17 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/74/294774/1

diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 6c84623..8ea2e5a 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -2450,7 +2450,7 @@
         * @return string
         */
        public function getVariableValue( $index, $frame = false ) {
-               global $wgContLang, $wgSitename, $wgServer, $wgServerName;
+               global $wgContLang, $wgSitename, $wgServer, $wgServerName, 
$wgMiserMode;
                global $wgArticlePath, $wgScriptPath, $wgStylePath;
 
                if ( is_null( $this->mTitle ) ) {
@@ -2462,10 +2462,8 @@
                                . ' called while parsing (no title set)' );
                }
 
-               /**
-                * Some of these require message or data lookups and can be
-                * expensive to check many times.
-                */
+               // Some of these require message or data lookups and can be
+               // expensive to check many times.
                if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$this, 
&$this->mVarCache ] ) ) {
                        if ( isset( $this->mVarCache[$index] ) ) {
                                return $this->mVarCache[$index];
@@ -2475,6 +2473,20 @@
                $ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() );
                Hooks::run( 'ParserGetVariableValueTs', [ &$this, &$ts ] );
 
+               // In miser mode, disable words that always cause double-parses 
on page save (T137900)
+               static $slowVaryWords = [
+                       'revisionid' => true,
+                       'revisiontimestamp' => true,
+                       'revisionday' => true,
+                       'revisionday2' => true,
+                       'revisionmonth' => true,
+                       'revisionmonth1' => true,
+                       'revisionyear' => true
+               ];
+               if ( $wgMiserMode && isset( $slowVaryWords[$index] ) ) {
+                       return '';
+               };
+
                $pageLang = $this->getFunctionLang();
 
                switch ( $index ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/294774
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieff8423ae3804b42d264f630e1a029199abf5976
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to