Make WordPress Core

Changeset 59373


Ignore:
Timestamp:
11/07/2024 11:45:40 PM (2 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r58993 r59373  
    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.
Note: See TracChangeset for help on using the changeset viewer.