Coding Standards: Ensure `$current` cookie time is `int` in `wp_user_settings()`.

This addresses an issue where a string (`$current`) is compared to an integer (`$last_saved`). The issue is resolved by casting the results of `preg_replace()` to type `int` when `$current` is defined.

Follow-up to [8784], [10083], [25109].

Props justlevine.
See #52217.
Built from https://develop.svn.wordpress.org/trunk@59373


git-svn-id: http://core.svn.wordpress.org/trunk@58759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-11-07 23:47:16 +00:00
parent 1013750a45
commit 1a6e117084
2 changed files with 6 additions and 2 deletions

View File

@ -1700,7 +1700,11 @@ function wp_user_settings() {
}
$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
$current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0;
$current = 0;
if ( isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ) {
$current = (int) preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] );
}
// The cookie is newer than the saved value. Update the user_option and leave the cookie as-is.
if ( $current > $last_saved ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59370';
$wp_version = '6.8-alpha-59373';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.