Pastakhov has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/381173 )
Change subject: Fix Timer::reset() function (version 5.11)
......................................................................
Fix Timer::reset() function (version 5.11)
Change-Id: I7755884993fb39669bbae5cd5af3d492b89b2f42
---
M PhpTags.hooks.php
M extension.json
M includes/Renderer.php
3 files changed, 22 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PhpTags
refs/changes/73/381173/1
diff --git a/PhpTags.hooks.php b/PhpTags.hooks.php
index 4a855e9..319ba14 100644
--- a/PhpTags.hooks.php
+++ b/PhpTags.hooks.php
@@ -16,7 +16,8 @@
* @return boolean
*/
public static function onPhpTagsRuntimeFirstInit() {
- \PhpTags\Hooks::addJsonFile( __DIR__ . '/PhpTags.json',
PHPTAGS_VERSION );
+ $version =
ExtensionRegistry::getInstance()->getAllThings()['Empty']['version'];
+ \PhpTags\Hooks::addJsonFile( __DIR__ . '/PhpTags.json',
$version );
return true;
}
@@ -89,7 +90,7 @@
$wgPhpTagsCallsCounter = 0;
define ( 'PHPTAGS_HOOK_RELEASE', 8 );
- define ( 'PHPTAGS_VERSION', '5.10' ); //@todo remove later, it
only for backward compatibility
+ define ( 'PHPTAGS_VERSION', '5.11' ); //@todo remove later, it
is for backward compatibility only
}
}
diff --git a/extension.json b/extension.json
index dbb6553..36aa437 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
{
"name": "PhpTags",
- "version": "5.10",
+ "version": "5.11",
"author": "[https://www.mediawiki.org/wiki/User:Pastakhov Pavel
Astakhov]",
"url": "https://www.mediawiki.org/wiki/Extension:PhpTags",
"descriptionmsg": "phptags-desc",
diff --git a/includes/Renderer.php b/includes/Renderer.php
index 8ff8e20..ef585a6 100644
--- a/includes/Renderer.php
+++ b/includes/Renderer.php
@@ -369,19 +369,26 @@
}
class Timer {
- private static $times = array();
+ private static $times = [];
private static $runTime = 0;
private static $compile = 0;
+ private static $reset = false; // allows to make a postponed reset
public static function start( $parser ) {
array_unshift( self::$times,
$parser->mOutput->getTimeSinceStart( 'cpu' ) );
}
public static function stop( $parser ) {
- if ( false === isset(self::$times[1]) ) {
+ if ( false === isset( self::$times[1] ) ) {
self::$runTime += $parser->mOutput->getTimeSinceStart(
'cpu' ) - self::$times[0];
}
array_shift( self::$times );
+
+ if ( self::$reset && !self::$times ) { // make a postponed reset
+ self::$reset = false;
+ self::$runTime = 0;
+ self::$compile = 0;
+ }
}
public static function addCompileTime( $parser ) {
@@ -397,7 +404,15 @@
}
public static function reset() {
- self::$times = array();
+ if ( isset( self::$times[0] ) ) { // the stop function was not
called
+ self::$reset = true; // postpone the real reset until
the stop function is called
+ } else {
+ self::realReset();
+ }
+ }
+
+ private static function realReset() {
+ self::$times = [];
self::$runTime = 0;
self::$compile = 0;
}
--
To view, visit https://gerrit.wikimedia.org/r/381173
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7755884993fb39669bbae5cd5af3d492b89b2f42
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PhpTags
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits