diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2020-06-14 02:37:57 +0100 |
---|---|---|
committer | Krinkle <krinklemail@gmail.com> | 2020-08-12 03:50:52 +0000 |
commit | 47ddeba2bd3c07d96e58fdaf678269e906498183 (patch) | |
tree | 12c1f6f381048b1a549d979f1ffe343d91abe3b5 /includes/profiler | |
parent | 16fc03ca1ad018730b9a7c9b8c8f947a55c6f1b0 (diff) | |
download | mediawikicore-47ddeba2bd3c07d96e58fdaf678269e906498183.tar.gz mediawikicore-47ddeba2bd3c07d96e58fdaf678269e906498183.zip |
profiler: Warn from ProfilerOutputDump::log() for incompatible profilers
The ProfilerOutputDump file dumper depends on the
ProfilerXhprof::getRawData() method. Check this explicitly.
Phan detects this but only for new code, in old code it was masked
with `@property` en-mass. This commit catches up with that debt.
Change-Id: I17a7cf32eb6a0d2ad52489080b2a1eab9df388ab
Diffstat (limited to 'includes/profiler')
-rw-r--r-- | includes/profiler/output/ProfilerOutputDump.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/includes/profiler/output/ProfilerOutputDump.php b/includes/profiler/output/ProfilerOutputDump.php index 68654e3ff7b5..e38e824fd4e5 100644 --- a/includes/profiler/output/ProfilerOutputDump.php +++ b/includes/profiler/output/ProfilerOutputDump.php @@ -18,15 +18,15 @@ * @file */ +use MediaWiki\Logger\LoggerFactory; + /** * Dump profiler data in a ".xhprof" file. * * @ingroup Profiler * @since 1.25 - * @property ProfilerXhprof $collector */ class ProfilerOutputDump extends ProfilerOutput { - protected $suffix = ".xhprof"; /** @@ -42,6 +42,11 @@ class ProfilerOutputDump extends ProfilerOutput { } public function log( array $stats ) { + if ( !$this->collector instanceof ProfilerXhprof ) { + $logger = LoggerFactory::getInstance( 'profiler' ); + $logger->error( 'ProfilerOutputDump must be used with ProfilerXhprof' ); + return; + } $data = $this->collector->getRawData(); $filename = sprintf( "%s/%s.%s%s", $this->params['outputDir'], |