Skip to content

Commit

Permalink
Support newer xhprof php extension (#5338)
Browse files Browse the repository at this point in the history
  • Loading branch information
paladox authored Oct 18, 2023
1 parent 3ce993e commit 7837991
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions LocalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7837991

Please sign in to comment.