Skip to content

Commit

Permalink
Script Loader: Check if error_reporting() exists in `load-(scripts|…
Browse files Browse the repository at this point in the history
…styles).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.

Follow-up to [50447].

Props gansbrest, sabernhardt, jrf, martin.krcho, SergeyBiryukov.
Fixes #61873.

git-svn-id: https://develop.svn.wordpress.org/trunk@58905 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Aug 16, 2024
1 parent 13d3c5e commit 4d8ac8b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 11 additions & 4 deletions src/wp-admin/load-scripts.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<?php

/*
* Disable error reporting.
*
* Set this to error_reporting( -1 ) for debugging.
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
* it's best to add a dummy function to the wp-config.php file, but as this call to the function
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
*/
error_reporting( 0 );
if ( function_exists( 'error_reporting' ) ) {
/*
* Disable error reporting.
*
* Set this to error_reporting( -1 ) for debugging.
*/
error_reporting( 0 );
}

// Set ABSPATH for execution.
if ( ! defined( 'ABSPATH' ) ) {
Expand Down
15 changes: 11 additions & 4 deletions src/wp-admin/load-styles.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<?php

/*
* Disable error reporting.
*
* Set this to error_reporting( -1 ) for debugging.
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
* it's best to add a dummy function to the wp-config.php file, but as this call to the function
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
*/
error_reporting( 0 );
if ( function_exists( 'error_reporting' ) ) {
/*
* Disable error reporting.
*
* Set this to error_reporting( -1 ) for debugging.
*/
error_reporting( 0 );
}

// Set ABSPATH for execution.
if ( ! defined( 'ABSPATH' ) ) {
Expand Down

0 comments on commit 4d8ac8b

Please sign in to comment.