From 783799166f32ffd9bb467456d66716d5809fde63 Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 18 Oct 2023 14:46:05 +0100 Subject: [PATCH] Support newer xhprof php extension (#5338) --- LocalSettings.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/LocalSettings.php b/LocalSettings.php index e4a22d5ff2..b01fe1d46e 100644 --- a/LocalSettings.php +++ b/LocalSettings.php @@ -28,9 +28,14 @@ * Disabled on production hosts because it seems to be causing performance issues (how ironic) */ $forceprofile = $_GET['forceprofile'] ?? 0; -if ( ( $forceprofile == 1 || PHP_SAPI === 'cli' ) && extension_loaded( 'tideways_xhprof' ) ) { - $xhprofFlags = TIDEWAYS_XHPROF_FLAGS_CPU | TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_NO_BUILTINS; - tideways_xhprof_enable( $xhprofFlags ); +if ( ( $forceprofile == 1 || PHP_SAPI === 'cli' ) && ( extension_loaded( 'tideways_xhprof' ) || extension_loaded( 'xhprof' ) ) ) { + if ( version_compare( PHP_VERSION, '8.2', '>=' ) ) { + $xhprofFlags = XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY; + xhprof_enable( $xhprofFlags ); + } else { + $xhprofFlags = TIDEWAYS_XHPROF_FLAGS_CPU | TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_NO_BUILTINS; + tideways_xhprof_enable( $xhprofFlags ); + } $wgProfiler = [ 'class' => ProfilerXhprof::class,