From ff3b8f6c894dab1ad976c9c1718b894fccdda162 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Tue, 13 Sep 2016 09:32:01 +1000 Subject: [PATCH 1/2] MDL-55921 profiling: Enable util script to be profiled. Enable util scripts to be profiled again and ensure that non-util script runs that don't include version.php are also able to provide some output. See David's commit for how export ensures version is used. --- lib/xhprof/xhprof_moodle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xhprof/xhprof_moodle.php b/lib/xhprof/xhprof_moodle.php index 9a4f850d2d04a..293ffacaad1e2 100644 --- a/lib/xhprof/xhprof_moodle.php +++ b/lib/xhprof/xhprof_moodle.php @@ -865,7 +865,7 @@ public function save_run($xhprof_data, $type, $run_id = null) { $DB->insert_record('profiling', $rec); - if (PHPUNIT_TEST && !PHPUNIT_UTIL) { + if (PHPUNIT_TEST) { // Calculate export variables. $tempdir = 'profiling'; make_temp_directory($tempdir); From 8beee5a4499b191559077fada628609e6504c392 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 8 Sep 2016 15:28:34 +0800 Subject: [PATCH 2/2] MDL-55921 profiling: Adding missing vars --- lib/xhprof/xhprof_moodle.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/xhprof/xhprof_moodle.php b/lib/xhprof/xhprof_moodle.php index 293ffacaad1e2..c930d4ff0e058 100644 --- a/lib/xhprof/xhprof_moodle.php +++ b/lib/xhprof/xhprof_moodle.php @@ -613,6 +613,13 @@ function profiling_import_runs($file, $commentprefix = '') { function profiling_export_generate(array $runids, $tmpdir) { global $CFG, $DB; + if (empty($CFG->release) || empty($CFG->version)) { + // Some scripts may not have included version.php. + include($CFG->dirroot.'/version.php'); + $CFG->release = $release; + $CFG->version = $version; + } + // Calculate the header information to be sent to moodle_profiling_runs.xml. $release = $CFG->release; $version = $CFG->version;