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
20191016 - MDL-65349 - Brendan Heywood (brendanheywood): Improved url matching behaviour
+20201012 - MDL-67081 - Brendan Heywood (brendanheywood): Support selective profiles from CLI
$script = !empty($SCRIPT) ? $SCRIPT : profiling_get_script();
// Get PGC variables
- $check = 'PROFILEME';
- $profileme = isset($_POST[$check]) || isset($_GET[$check]) || isset($_COOKIE[$check]) ? true : false;
- $profileme = $profileme && !empty($CFG->profilingallowme);
- $check = 'DONTPROFILEME';
- $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);
+ $profileme = profiling_get_flag('PROFILEME') && !empty($CFG->profilingallowme);
+ $dontprofileme = profiling_get_flag('DONTPROFILEME') && !empty($CFG->profilingallowme);
+ $profileall = profiling_get_flag('PROFILEALL') && !empty($CFG->profilingallowall);
+ $profileallstop = profiling_get_flag('PROFILEALLSTOP') && !empty($CFG->profilingallowall);
// DONTPROFILEME detected, nothing to start
if ($dontprofileme) {
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
*/