[wp-trac] [WordPress Trac] #57728: PHP 8.1 deprecation notice for gmt_offset on wp-admin/options.php
WordPress Trac
noreply at wordpress.org
Wed Feb 15 22:26:03 UTC 2023
#57728: PHP 8.1 deprecation notice for gmt_offset on wp-admin/options.php
----------------------------+-----------------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version:
Severity: normal | Keywords: php81
Focuses: |
----------------------------+-----------------------------
1. In General Settings, select a named timezone (not a UTC+- one).
2. When saving the settings, there is a PHP 8.1 deprecation notice:
{{{
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of
type array|string is deprecated in wp-includes/formatting.php on line 4862
}}}
The notice comes from `sanitize_option()`:
{{{
case 'gmt_offset':
$value = preg_replace( '/[^0-9:.-]/', '', $value ); // Strips
slashes.
break;
}}}
Appears to be caused by this fragment in `wp-admin/options.php` where the
default value for any options not passed in the current `$_POST` request
(which happens to be `gmt_offset` here) is set to `null`:
{{{
foreach ( $options as $option ) {
...
$option = trim( $option );
$value = null;
if ( isset( $_POST[ $option ] ) ) {
$value = $_POST[ $option ];
if ( ! is_array( $value ) ) {
$value = trim( $value );
}
$value = wp_unslash( $value );
}
update_option( $option, $value );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57728>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list