Skip to content

Commit 4d8ac8b

Browse files
Script Loader: Check if error_reporting() exists in load-(scripts|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
1 parent 13d3c5e commit 4d8ac8b

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/wp-admin/load-scripts.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?php
22

33
/*
4-
* Disable error reporting.
5-
*
6-
* Set this to error_reporting( -1 ) for debugging.
4+
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
5+
* it's best to add a dummy function to the wp-config.php file, but as this call to the function
6+
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
77
*/
8-
error_reporting( 0 );
8+
if ( function_exists( 'error_reporting' ) ) {
9+
/*
10+
* Disable error reporting.
11+
*
12+
* Set this to error_reporting( -1 ) for debugging.
13+
*/
14+
error_reporting( 0 );
15+
}
916

1017
// Set ABSPATH for execution.
1118
if ( ! defined( 'ABSPATH' ) ) {

src/wp-admin/load-styles.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?php
22

33
/*
4-
* Disable error reporting.
5-
*
6-
* Set this to error_reporting( -1 ) for debugging.
4+
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
5+
* it's best to add a dummy function to the wp-config.php file, but as this call to the function
6+
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
77
*/
8-
error_reporting( 0 );
8+
if ( function_exists( 'error_reporting' ) ) {
9+
/*
10+
* Disable error reporting.
11+
*
12+
* Set this to error_reporting( -1 ) for debugging.
13+
*/
14+
error_reporting( 0 );
15+
}
916

1017
// Set ABSPATH for execution.
1118
if ( ! defined( 'ABSPATH' ) ) {

0 commit comments

Comments
 (0)