mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-67081 xhprof: Allow conditional profiling from CLI using env vars
This commit is contained in:
parent
6ef4e66f03
commit
7f97d1181d
2 changed files with 17 additions and 12 deletions
|
@ -41,4 +41,5 @@ TODO:
|
||||||
20171002 - MDL-60313 - Marina Glancy (marinaglancy): Upgrade to 0.9.4 release; patched for PHP7.2
|
20171002 - MDL-60313 - Marina Glancy (marinaglancy): Upgrade to 0.9.4 release; patched for PHP7.2
|
||||||
20190314 - MDL-64543 - Brendan Heywood (brendanheywood): Add support for conditional slow profiling
|
20190314 - MDL-64543 - Brendan Heywood (brendanheywood): Add support for conditional slow profiling
|
||||||
20191016 - MDL-65349 - Brendan Heywood (brendanheywood): Improved url matching behaviour
|
20191016 - MDL-65349 - Brendan Heywood (brendanheywood): Improved url matching behaviour
|
||||||
|
20201012 - MDL-67081 - Brendan Heywood (brendanheywood): Support selective profiles from CLI
|
||||||
|
|
||||||
|
|
|
@ -103,18 +103,10 @@ function profiling_start() {
|
||||||
$script = !empty($SCRIPT) ? $SCRIPT : profiling_get_script();
|
$script = !empty($SCRIPT) ? $SCRIPT : profiling_get_script();
|
||||||
|
|
||||||
// Get PGC variables
|
// Get PGC variables
|
||||||
$check = 'PROFILEME';
|
$profileme = profiling_get_flag('PROFILEME') && !empty($CFG->profilingallowme);
|
||||||
$profileme = isset($_POST[$check]) || isset($_GET[$check]) || isset($_COOKIE[$check]) ? true : false;
|
$dontprofileme = profiling_get_flag('DONTPROFILEME') && !empty($CFG->profilingallowme);
|
||||||
$profileme = $profileme && !empty($CFG->profilingallowme);
|
$profileall = profiling_get_flag('PROFILEALL') && !empty($CFG->profilingallowall);
|
||||||
$check = 'DONTPROFILEME';
|
$profileallstop = profiling_get_flag('PROFILEALLSTOP') && !empty($CFG->profilingallowall);
|
||||||
$dontprofileme = isset($_POST[$check]) || isset($_GET[$check]) || isset($_COOKIE[$check]) ? true : false;
|
|
||||||
$dontprofileme = $dontprofileme && !empty($CFG->profilingallowme);
|
|
||||||
$check = 'PROFILEALL';
|
|
||||||
$profileall = isset($_POST[$check]) || isset($_GET[$check]) || isset($_COOKIE[$check]) ? true : false;
|
|
||||||
$profileall = $profileall && !empty($CFG->profilingallowall);
|
|
||||||
$check = 'PROFILEALLSTOP';
|
|
||||||
$profileallstop = isset($_POST[$check]) || isset($_GET[$check]) || isset($_COOKIE[$check]) ? true : false;
|
|
||||||
$profileallstop = $profileallstop && !empty($CFG->profilingallowall);
|
|
||||||
|
|
||||||
// DONTPROFILEME detected, nothing to start
|
// DONTPROFILEME detected, nothing to start
|
||||||
if ($dontprofileme) {
|
if ($dontprofileme) {
|
||||||
|
@ -189,6 +181,18 @@ function profiling_start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for profiling flags in all possible places
|
||||||
|
* @param string $flag name
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function profiling_get_flag($flag) {
|
||||||
|
return !empty(getenv($flag)) ||
|
||||||
|
isset($_COOKIE[$flag]) ||
|
||||||
|
isset($_POST[$flag]) ||
|
||||||
|
isset($_GET[$flag]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop profiling, gathering results and storing them
|
* Stop profiling, gathering results and storing them
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue