profiler: Set Xhprof::$enabled after enable attempt, not before
Previously, if you tried to configure $wgProfiler to use Tideways or XHProf, but did not actually have it (correctly) installed as a PHP extension, then the exception shown to the developer was "Exception: Profiling is already enabled.", whereas they should be shown "Exception: Neither xhprof nor tideways are installed". Here is how that happened: * LocalSettings has $wgProfiler enabled. * MediaWiki initialises Profiler::singleton() at some point. This calls Profiler -> ProfilerXhprof -> Xhprof::enable. * Xhprof::enable() sets $enabled=true and then tries to do the actual enabling via callAny(). * Xhprof::callAny() finds that the user has no driver installed, so it throws the (correct) Exception. * The uncaught exception is handled by MWExceptionHandler and results in an error page being prepared. At some point, we hit a service constructor that will need a Profiler, which given it threw earlier, does not yet have a singleton to re-use, so it tries again. This calls Profiler -> ProfilerXhprof -> Xhprof::enable. * Xhprof::enable (hello again), now throws because its $enabled member was already set to true! To fix this, simply move the assignment two lines down. Change-Id: I89e31fe58a1c77ee2542628bec4d7bc97621ef4f
This commit is contained in:
parent
8cf4438839
commit
ad7e5d5047
1 changed files with 1 additions and 1 deletions
|
|
@ -57,7 +57,6 @@ class Xhprof {
|
|||
$args[] = $options;
|
||||
}
|
||||
|
||||
self::$enabled = true;
|
||||
self::callAny(
|
||||
[
|
||||
'xhprof_enable',
|
||||
|
|
@ -66,6 +65,7 @@ class Xhprof {
|
|||
],
|
||||
$args
|
||||
);
|
||||
self::$enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue