Ori.livneh has uploaded a new change for review.

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

Change subject: Make edit preview detection less expensive
......................................................................

Make edit preview detection less expensive

Checking if frame:preprocess("{{REVISIONID}}") == '' is a popular trick for
determining whether the current parse operation is for an edit preview, in
which case modules often want to add debug info to the HTML. It's not pretty
and we don't sanction it, but we can at least make it cheap.

Change-Id: I5aa3b29e5913e73cc09bbf7795c55786e67628fe
---
M engines/LuaCommon/LuaCommon.php
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/37/294437/1

diff --git a/engines/LuaCommon/LuaCommon.php b/engines/LuaCommon/LuaCommon.php
index dd1f996..066e6cc 100644
--- a/engines/LuaCommon/LuaCommon.php
+++ b/engines/LuaCommon/LuaCommon.php
@@ -769,6 +769,15 @@
                        throw new Scribunto_LuaError( 'attempt to call 
mw.preprocess with no frame' );
                }
 
+               // Checking if frame:preprocess("{{REVISIONID}}") == '' is a 
popular
+               // trick for determining whether the current parse operation is 
for
+               // an edit preview, in which case modules often want to add 
debug
+               // info to the HTML. It's not pretty and we don't sanction it, 
but
+               // we can at least make it cheap.
+               if ( $text === '{{REVISIONID}}' ) {
+                       return array( $this->getParser()->getRevisionId() );
+               }
+
                // Don't count the time for expanding all the frame arguments 
against
                // the Lua time limit.
                $this->getInterpreter()->pauseUsageTimer();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5aa3b29e5913e73cc09bbf7795c55786e67628fe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>

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

Reply via email to