X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2FXhprof.php;h=8175427d8d0b5f187d8f906970b5ca151228e17d;hb=6129d1d704a9833b23c92a371fe54475323cc190;hp=e58d98fcc3bf10d2d62aa4a983e83a49e9af52be;hpb=5120937028f768749d058aa91dde82a96de0af1c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/Xhprof.php b/includes/libs/Xhprof.php index e58d98fcc3..8175427d8d 100644 --- a/includes/libs/Xhprof.php +++ b/includes/libs/Xhprof.php @@ -54,13 +54,14 @@ class Xhprof { throw new Exception( 'Profiling is already enabled.' ); } self::$enabled = true; - if ( function_exists( 'xhprof_enable' ) ) { - xhprof_enable( $flags, $options ); - } elseif ( function_exists( 'tideways_enable' ) ) { - tideways_enable( $flags, $options ); - } else { - throw new Exception( "Neither xhprof nor tideways are installed" ); - } + self::callAny( + [ + 'xhprof_enable', + 'tideways_enable', + 'tideways_xhprof_enable' + ], + [ $flags, $options ] + ); } /** @@ -71,12 +72,27 @@ class Xhprof { public static function disable() { if ( self::isEnabled() ) { self::$enabled = false; - if ( function_exists( 'xhprof_disable' ) ) { - return xhprof_disable(); - } else { - // tideways - return tideways_disable(); + return self::callAny( [ + 'xhprof_disable', + 'tideways_disable', + 'tideways_xhprof_disable' + ] ); + } + } + + /** + * Call the first available function from $functions. + * @param array $functions + * @param array $args + * @throws Exception + */ + protected static function callAny( array $functions, array $args = [] ) { + foreach ( $functions as $func ) { + if ( function_exists( $func ) ) { + return $func( ...$args ); } } + + throw new Exception( "Neither xhprof nor tideways are installed" ); } }