From 73a7e327ea8228bde56a9b14920e2d6b103a10af Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Thu, 18 May 2017 16:03:25 +0300 Subject: [PATCH] Removed xhprof_lib dependency when writing profiler data. (#967) - Maintains functionality while eliminating the need to add xhprof_lib to the PHP include path. --- config/vufind/httpd-vufind.conf | 3 +-- public/index.php | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/vufind/httpd-vufind.conf b/config/vufind/httpd-vufind.conf index 1c6f9499730..5fa16bf7710 100644 --- a/config/vufind/httpd-vufind.conf +++ b/config/vufind/httpd-vufind.conf @@ -61,8 +61,7 @@ Alias /vufind /usr/local/vufind/public #SetEnv VUFIND_ENV development # Uncomment this line if you want to use the XHProf or Tideways profiler; this is a - # developer-oriented option that most users will not need. Make sure the XHProf PHP - # libraries are available on your include path. + # developer-oriented option that most users will not need. # See https://vufind.org/wiki/development:profiling for more details. #SetEnv VUFIND_PROFILER_XHPROF http://url/to/your/xhprof/web/interface diff --git a/public/index.php b/public/index.php index 39a1e9681ea..0ffe5e85396 100644 --- a/public/index.php +++ b/public/index.php @@ -85,11 +85,13 @@ Zend\Mvc\Application::init(require 'config/application.config.php')->run(); // Handle final profiling details, if necessary: if ($xhprof) { $xhprofData = extension_loaded('xhprof') ? xhprof_disable() : tideways_disable(); - require_once "xhprof_lib/utils/xhprof_lib.php"; - require_once "xhprof_lib/utils/xhprof_runs.php"; - $xhprofRuns = new XHProfRuns_Default(); + $xhprofRunId = uniqid(); $suffix = 'vufind'; - $xhprofRunId = $xhprofRuns->save_run($xhprofData, $suffix); + $dir = ini_get('xhprof.output_dir'); + if (empty($dir)) { + $dir = sys_get_temp_dir(); + } + file_put_contents("$dir/$xhprofRunId.$suffix.xhprof", serialize($xhprofData)); $url = "$xhprof?run=$xhprofRunId&source=$suffix"; echo "<a href='$url'>Profiler output</a>"; } -- GitLab