From 666e830b253eb467a05579bd931bed0affc7e64d Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 8 Apr 2024 12:10:28 +0800 Subject: [PATCH 1/2] MDL-81459 core: Add missing legacy callback for header hook --- lib/outputrenderers.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 0fef2261c537d..d478320ccbd10 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1365,7 +1365,9 @@ public function header() { // TODO MDL-81134 Remove after LTS+1. require_once(__DIR__ . '/classes/hook/output/before_http_headers.php'); - di::get(hook_manager::class)->dispatch(new before_http_headers($this)); + $hook = new before_http_headers($this); + $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); if (\core\session\manager::is_loggedinas()) { $this->page->add_body_class('userloggedinas'); From 5ff5cf8203da7b20240bcfee7de51d5909dc92c9 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 8 Apr 2024 12:10:41 +0800 Subject: [PATCH 2/2] MDL-81459 core: Correct order of legacy callback processing --- lib/outputrenderers.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index d478320ccbd10..eb48876e4d1e1 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -672,8 +672,8 @@ public function htmlattributes() { $hook->add_attribute('xmlns', 'http://www.w3.org/1999/xhtml'); } - di::get(hook_manager::class)->dispatch($hook); $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); foreach ($hook->get_attributes() as $key => $val) { $val = s($val); @@ -706,8 +706,8 @@ public function standard_head_html() { // must always return a string containing valid html head content. $hook = new \core\hook\output\before_standard_head_html_generation($this); - di::get(hook_manager::class)->dispatch($hook); $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); // Allow a url_rewrite plugin to setup any dynamic head content. if (isset($CFG->urlrewriteclass) && !isset($CFG->upgraderunning)) { @@ -820,8 +820,8 @@ public function standard_top_of_body_html() { // Allow components to add content to the top of the body. $hook = new before_standard_top_of_body_html_generation($this, $output); - di::get(hook_manager::class)->dispatch($hook); $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); $output = $hook->get_output(); $output .= $this->maintenance_warning(); @@ -885,8 +885,8 @@ public function standard_footer_html() { require_once(__DIR__ . '/classes/hook/output/before_standard_footer_html_generation.php'); $hook = new before_standard_footer_html_generation($this); - di::get(hook_manager::class)->dispatch($hook); $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); $output = $hook->get_output(); if ($this->page->devicetypeinuse == 'legacy') { @@ -1122,8 +1122,8 @@ public function standard_after_main_region_html() { $hook->add_html($CFG->additionalhtmlbottomofbody); } - di::get(hook_manager::class)->dispatch($hook); $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); return $hook->get_output(); } @@ -1491,8 +1491,8 @@ public function footer() { require_once(__DIR__ . '/classes/hook/output/before_footer_html_generation.php'); $hook = new before_footer_html_generation($this); - di::get(hook_manager::class)->dispatch($hook); $hook->process_legacy_callbacks(); + di::get(hook_manager::class)->dispatch($hook); $hook->add_html($this->container_end_all(true)); $output = $hook->get_output();