jenkins-bot has submitted this change and it was merged.
Change subject: Switched hook profiling to use scopedProfileIn
......................................................................
Switched hook profiling to use scopedProfileIn
* Also made scopedProfileOut handle the case where the callback
was null (e.g. when there are no frame methods for xhprof).
Change-Id: Ife242bda8e046990d0d8ac27d628975b7b4a14d7
---
M includes/Hooks.php
M includes/profiler/ProfilerStub.php
M includes/profiler/ProfilerXhprof.php
3 files changed, 13 insertions(+), 8 deletions(-)
Approvals:
BryanDavis: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 668c3d9..44f78a5 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -134,7 +134,9 @@
* @throws FatalError
*/
public static function run( $event, array $args = array(),
$deprecatedVersion = null ) {
- wfProfileIn( 'hook: ' . $event );
+ $profiler = Profiler::instance();
+ $eventPS = $profiler->scopedProfileIn( 'hook: ' . $event );
+
foreach ( self::getHandlers( $event ) as $hook ) {
// Turn non-array values into an array. (Can't use
casting because of objects.)
if ( !is_array( $hook ) ) {
@@ -193,8 +195,8 @@
$badhookmsg = null;
$hook_args = array_merge( $hook, $args );
- // Profile first in case the Profiler causes errors.
- wfProfileIn( $func );
+ // Profile first in case the Profiler causes errors
+ $funcPS = $profiler->scopedProfileIn( $func );
set_error_handler( 'Hooks::hookErrorHandler' );
// mark hook as deprecated, if deprecation version is
specified
@@ -210,8 +212,9 @@
restore_error_handler();
throw $e;
}
+
restore_error_handler();
- wfProfileOut( $func );
+ $profiler->scopedProfileOut( $funcPS );
// Process the return value.
if ( is_string( $retval ) ) {
@@ -224,13 +227,11 @@
"Hook $func has invalid call signature;
" . $badhookmsg
);
} elseif ( $retval === false ) {
- wfProfileOut( 'hook: ' . $event );
// False was returned. Stop processing, but no
error.
return false;
}
}
- wfProfileOut( 'hook: ' . $event );
return true;
}
diff --git a/includes/profiler/ProfilerStub.php
b/includes/profiler/ProfilerStub.php
index b400601..2db06e4 100644
--- a/includes/profiler/ProfilerStub.php
+++ b/includes/profiler/ProfilerStub.php
@@ -34,7 +34,9 @@
}
public function scopedProfileIn( $section ) {
- return null;
+ return new ScopedCallback( function() {
+ // no-op
+ } );
}
public function getFunctionStats() {
diff --git a/includes/profiler/ProfilerXhprof.php
b/includes/profiler/ProfilerXhprof.php
index 808c5cd..d91b429 100644
--- a/includes/profiler/ProfilerXhprof.php
+++ b/includes/profiler/ProfilerXhprof.php
@@ -131,7 +131,9 @@
} );
}
- return null;
+ return new ScopedCallback( function() {
+ // no-op
+ } );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/177449
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ife242bda8e046990d0d8ac27d628975b7b4a14d7
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits