Skip to content

Commit

Permalink
Fix headers already sent for yes and debug modes
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkshire-pudding committed Jul 4, 2024
1 parent 5839401 commit 5daf7b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion includes/command.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function bee_parse_input() {
* Get the callback function for the command and process it.
*/
function bee_process_command() {
global $_bee_command, $_bee_arguments, $_bee_options, $_bee_command_aliases, $_bee_output;
global $_bee_command, $_bee_arguments, $_bee_options, $_bee_command_aliases, $_bee_output, $_bee_yes_mode, $_bee_debug_mode;

// Display help text if no command is given.
if (empty($_bee_command)) {
Expand Down Expand Up @@ -88,6 +88,14 @@ function bee_process_command() {
}

if ($ready) {
// Notify about Yes mode and Debug mode if enabled. This must be done
// after Backdrop has been bootstrapped, if applicable.
if ($_bee_yes_mode) {
bee_instant_message(bt("'Yes' mode enabled."));
}
if ($_bee_debug_mode) {
bee_instant_message(bt("'Debug' mode enabled."));
}
$_bee_output = $callback($_bee_arguments, $_bee_options);
}
else {
Expand Down
2 changes: 0 additions & 2 deletions includes/miscellaneous.inc
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ function bee_initialize_console() {
// Turn on various 'modes' as appropriate.
if (!empty($_bee_options['yes']) || !empty($_bee_options['y'])) {
$_bee_yes_mode = TRUE;
bee_instant_message(bt("'Yes' mode enabled."));
}
if (!empty($_bee_options['debug']) || !empty($_bee_options['d'])) {
$_bee_debug_mode = TRUE;
bee_instant_message(bt("'Debug' mode enabled."));
}
}

Expand Down
6 changes: 6 additions & 0 deletions includes/render.inc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ function bee_render_text(array $variables, $newline = TRUE) {
* - It includes the ability to output an array of data after the message for
* 'debug' messages.
* - It includes the calling function and line number for 'debug' messages.
*
* WARNING: If you insert a call to this function in the core bee code before
* a command that requires Backdrop to be boostrapped, it will produce
* 'Headers already sent' warnings so only use temporarily for debug
* purposes.
*
* @param string $message
* The translated message to display.
* @param string $type
Expand Down

0 comments on commit 5daf7b6

Please sign in to comment.