Skip to content

Commit 2b99f6d

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59373 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9503db2 commit 2b99f6d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/wp-includes/option.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,11 @@ function wp_user_settings() {
17001700
}
17011701

17021702
$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
1703-
$current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0;
1703+
$current = 0;
1704+
1705+
if ( isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ) {
1706+
$current = (int) preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] );
1707+
}
17041708

17051709
// The cookie is newer than the saved value. Update the user_option and leave the cookie as-is.
17061710
if ( $current > $last_saved ) {

0 commit comments

Comments
 (0)