WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 18 months ago

#47266 new defect (bug)

Template of shutdown handler for fatal errors should not be displayed for CLI scripts

Reported by: iandunn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: servehappy needs-patch
Focuses: Cc:

Description (last modified by ocean90)

When running a CLI script that has a syntax error, the template's raw HTML and CSS are output to the command line.

I don't think that the shutdown handler for fatal errors should be loaded in a CLI context; instead, the default PHP behavior should be used instead.

This should handle the case where the CLI script is being run through WP-CLI, and also older scripts that were built before WP-CLI existed, which just load WP manually (i.e., check 'cli' === php_sapi_name() rather than defined( 'WP_CLI' ) ).

Change History (5)

#1 follow-up: @ocean90
19 months ago

  • Description modified (diff)
  • Keywords servehappy added; site-health removed
  • Summary changed from Site health template should not be displayed for CLI scripts to Template of shutdown handler for fatal errors should not be displayed for CLI scripts

An alternative would be to add a wp_die handler for CLI context.

#2 in reply to: ↑ 1 @SergeyBiryukov
19 months ago

Replying to ocean90:

An alternative would be to add a wp_die handler for CLI context.

We have (currently unused) _scalar_wp_die_handler(), which seems like a good fit.

Introduced in [20063], unused since [21818].

#3 @desrosj
19 months ago

  • Keywords needs-patch added

This ticket was mentioned in Slack in #core-php by spacedmonkey. View the logs.


18 months ago

#5 @spacedmonkey
18 months ago

  • Component changed from Administration to Site Health
Note: See TracTickets for help on using tickets.