From 373e8c7d05a648cf71c9327087e38b1bf3da3d13 Mon Sep 17 00:00:00 2001 From: Brian Foley Date: Fri, 23 Oct 2026 00:26:16 +0100 Subject: [PATCH] Get output_page_header etc to log if it's ever called more than once The code was audited some time ago to remove duplicate calls, but now we want to see if we can remove the guard entirely. --- pinc/html_page_common.inc | 8 +++++--- pinc/slim_header.inc | 8 +++++--- tools/project_manager/generate_post_files.php | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pinc/html_page_common.inc b/pinc/html_page_common.inc index 4bd61d843..0acdf3526 100644 --- a/pinc/html_page_common.inc +++ b/pinc/html_page_common.inc @@ -19,11 +19,13 @@ function output_html_header(?string $nameofpage, array $extra_args = [], bool $s { global $code_url; - static $was_output = false; - if ($was_output) { + static $output_caller = null; + if (!is_null($output_caller)) { + $loc = get_backtrace_loc(); + error_log("output_html_header: called from $output_caller then $loc"); return; } - $was_output = true; + $output_caller = get_backtrace_loc(); $user = User::load_current(); diff --git a/pinc/slim_header.inc b/pinc/slim_header.inc index c01e7ca6c..cba1fcccb 100644 --- a/pinc/slim_header.inc +++ b/pinc/slim_header.inc @@ -34,12 +34,14 @@ function slim_footer(array $extra_args = []): void { // Despite not needing to, some pages may still be calling slim_footer // so check to see if we've already output the footer. - static $was_output = false; - if ($was_output) { + static $output_caller = null; + if (!is_null($output_caller)) { + $loc = get_backtrace_loc(); + error_log("slim_footer: called from $output_caller then $loc"); return; } output_html_footer($extra_args); - $was_output = true; + $output_caller = get_backtrace_loc(); } diff --git a/tools/project_manager/generate_post_files.php b/tools/project_manager/generate_post_files.php index 40331f2c5..f05993b20 100644 --- a/tools/project_manager/generate_post_files.php +++ b/tools/project_manager/generate_post_files.php @@ -67,11 +67,13 @@ function output_page_header(Project $project): void // Allow this function to be called multiple times but only output // the contents once. - static $was_output = false; - if ($was_output) { + static $output_caller = null; + if (!is_null($output_caller)) { + $loc = get_backtrace_loc(); + error_log("output_page_header: called from $output_caller then $loc"); return; } - $was_output = true; + $output_caller = get_backtrace_loc(); $title = _("Generating Post Files"); slim_header($title);