MDL-79276 core: Fix perfdebug footer bug in non html pages

This commit is contained in:
Brendan Heywood
2023-10-02 21:11:44 +10:00
parent 79c2e4bdae
commit 21b5ad1555
2 changed files with 6 additions and 10 deletions
+4 -9
View File
@@ -195,7 +195,7 @@ class core_shutdown_manager {
* Standard shutdown sequence.
*/
protected static function request_shutdown() {
global $CFG, $OUTPUT;
global $CFG, $OUTPUT, $PERF;
// Help apache server if possible.
$apachereleasemem = false;
@@ -216,14 +216,9 @@ class core_shutdown_manager {
$perf = get_performance_info();
error_log("PERF: " . $perf['txt']);
}
if (MDL_PERFTOFOOT || debugging() || (!empty($CFG->perfdebug) && $CFG->perfdebug > 7)) {
if (NO_OUTPUT_BUFFERING) {
// If the performance footer was deferred then print it now.
if (!CLI_SCRIPT && !WS_SERVER) {
$perf = get_performance_info();
echo $OUTPUT->select_element_for_replace('#perfdebugfooter', $perf['html']);
}
}
if (!empty($PERF->perfdebugdeferred)) {
$perf = get_performance_info();
echo $OUTPUT->select_element_for_replace('#perfdebugfooter', $perf['html']);
}
if (MDL_PERFINC) {
$inc = get_included_files();
+2 -1
View File
@@ -1489,7 +1489,7 @@ class core_renderer extends renderer_base {
* @return string HTML fragment
*/
public function footer() {
global $CFG, $DB;
global $CFG, $DB, $PERF;
$output = '';
@@ -1519,6 +1519,7 @@ class core_renderer extends renderer_base {
if (NO_OUTPUT_BUFFERING) {
// If the output buffer was off then we render a placeholder and stream the
// performance debugging into it at the very end in the shutdown handler.
$PERF->perfdebugdeferred = true;
$performanceinfo .= html_writer::tag('div',
get_string('perfdebugdeferred', 'admin'),
[