WordPress.org

Make WordPress Core

Opened 15 months ago

Closed 13 months ago

Last modified 13 months ago

#46069 closed defect (bug) (fixed)

WP_CONTENT_DIR in wp_register_fatal_error_handler

Reported by: sebastian.pisula Owned by: SergeyBiryukov
Milestone: 5.2 Priority: normal
Severity: normal Version: 5.1
Component: Bootstrap/Load Keywords: has-patch
Focuses: Cc:

Description

I think this is a problem. My case:

I created file fatal-error-handler.php in wp-content directory. In the file I put the code:

<?php

class IC_Fatal_Error_Handler extends WP_Fatal_Error_Handler {
        public function handle() {
                wp_die( 'error' );
        }
}

return new IC_Fatal_Error_Handler();

And nothing. The file isn't loaded. I think that wp_register_fatal_error_handler() should be call after calling wp_initial_constants()

Attachments (1)

46069.patch (1.1 KB) - added by sebastian.pisula 15 months ago.

Download all attachments as: .zip

Change History (7)

#2 @pento
15 months ago

  • Milestone changed from Awaiting Review to 5.2

#3 @diddledan
13 months ago

The conditional check in wp-includes/error-protection.php will always fail so the drop-in file will never be loaded. It checks for defined( 'WP_CONTENT_DIR' ) which will always be false unless the site owner has explicitly set it in wp-config.php. This is because the default definition of this constant is later in the lifecycle.

This ticket was mentioned in Slack in #core by diddledan. View the logs.


13 months ago

#5 @SergeyBiryukov
13 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 45056:

Bootstrap/Load: Ensure the fatal error handler is registered after WP_CONTENT_DIR is defined, so the custom error handler drop-in could be properly loaded.

Props sebastian.pisula, diddledan.
Fixes #46069.

#6 @SergeyBiryukov
13 months ago

  • Component changed from General to Bootstrap/Load
Note: See TracTickets for help on using tickets.