Skip to content

Commit

Permalink
Internal: Fix xhprof loading for new Tideways library version
Browse files Browse the repository at this point in the history
  • Loading branch information
ywarnier committed Nov 2, 2022
1 parent 4b6f03f commit c69c790
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/xhprof/README.md
Expand Up @@ -7,7 +7,7 @@ forked it, between other reasons to provide support for PHP 7.
## Install procedure

To enable the profiler into Chamilo, you will need to do the following:
- install the tideways-php library from https://tideways.io/profiler/downloads
- install the php[version]-tideways library from https://tideways.io/profiler/downloads or your package manager
- add the following two lines to your Apache VirtualHost or (in a slightly different form) to your php.ini config
(don't forget to update the path to your Chamilo root directory):
```
Expand All @@ -19,6 +19,7 @@ To enable the profiler into Chamilo, you will need to do the following:
```
# Deny access
#RewriteRule ^(tests|.git) - [F,L,NC]
RewriteRule ^.git - [F,L,NC]
```

## Using XHProf
Expand Down
5 changes: 3 additions & 2 deletions tests/xhprof/footer.php
Expand Up @@ -5,12 +5,13 @@
/**
* Init
*/
use Tideways\Profiler;

$isAjaxRequest = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';

if (extension_loaded('tideways') && !$isAjaxRequest) {
if (extension_loaded('tideways_xhprof') && !$isAjaxRequest) {
$profiler_namespace = 'chamilolms'; // namespace for your application
$xhprof_data = tideways_disable();
$xhprof_data = tideways_xhprof_disable();
//$xhprof_runs = new XHProfRuns_Default();
//$run_id = $xhprof_runs->save_run($xhprof_data, $profiler_namespace);
$run_id = uniqid();
Expand Down
5 changes: 3 additions & 2 deletions tests/xhprof/header.php
Expand Up @@ -11,11 +11,12 @@
* in your php config also disable the .htaccess line about the tests/
* directory.
*/
use Tideways\Profiler;

$isAjaxRequest = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';

if (extension_loaded('tideways') && !$isAjaxRequest) {
if (extension_loaded('tideways_xhprof') && !$isAjaxRequest) {
//include_once __DIR__.'/xhprof_lib/utils/xhprof_lib.php';
//include_once __DIR__.'/xhprof_lib/utils/xhprof_runs.php';
tideways_enable(TIDEWAYS_FLAGS_NO_SPANS);
tideways_xhprof_enable();
}

0 comments on commit c69c790

Please sign in to comment.