WordPress.org

Make WordPress Core

Changeset 50447


Ignore:
Timestamp:
02/27/2021 11:07:29 AM (3 months ago)
Author:
SergeyBiryukov
Message:

Bootstrap/Load: Check if the error_reporting() function exists in wp-load.php.

This avoids a fatal error on PHP 8 if error_reporting() is disabled in php.ini.

On systems with this function disabled, it's best to add a dummy function to the wp-config.php file, as there are multiple other calls in core or plugins.

However, as this call to the function is run prior to wp-config.php loading, it is now wrapped in a function_exists() check.

Props peterwilsoncc, fijisunshine, ayeshrajans.
Fixes #52226.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-load.php

    r49953 r50447  
    2222}
    2323
    24 error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
     24/*
     25 * The error_reporting() function can be disabled in php.ini. On systems where that is the case,
     26 * it's best to add a dummy function to the wp-config.php file, but as this call to the function
     27 * is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
     28 */
     29if ( function_exists( 'error_reporting' ) ) {
     30    error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
     31}
    2532
    2633/*
Note: See TracChangeset for help on using the changeset viewer.