Ticket #41937: 41937.patch
File 41937.patch, 5.6 KB (added by , 7 years ago) |
---|
-
src/wp-includes/default-constants.php
239 239 define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH); 240 240 241 241 /** 242 * @since 4.9.0 243 */ 244 if ( ! defined( 'SETTINGS_COOKIE' ) ) { 245 define( 'SETTINGS_COOKIE', 'wp-settings-' ); 246 } 247 248 /** 249 * @since 4.9.0 250 */ 251 if ( ! defined( 'SETTINGS_TIME_COOKIE' ) ) { 252 define( 'SETTINGS_TIME_COOKIE', 'wp-settings-time-' ); 253 } 254 255 /** 242 256 * @since 2.3.0 243 257 */ 244 258 if ( !defined('TEST_COOKIE') ) -
src/wp-includes/js/utils.js
157 157 } 158 158 159 159 var uid = userSettings.uid, 160 settings = wpCookies.getHash( 'wp-settings-'+ uid ),160 settings = wpCookies.getHash( userSettings.settingsCookie + uid ), 161 161 path = userSettings.url, 162 162 secure = !! userSettings.secure; 163 163 … … 177 177 settings[name] = value; 178 178 } 179 179 180 wpCookies.setHash( 'wp-settings-'+ uid, settings, 31536000, path, '', secure );181 wpCookies.set( 'wp-settings-time-'+ uid, userSettings.time, 31536000, path, '', secure );180 wpCookies.setHash( userSettings.settingsCookie + uid, settings, 31536000, path, '', secure ); 181 wpCookies.set( userSettings.settingsTimeCookie + uid, userSettings.time, 31536000, path, '', secure ); 182 182 183 183 return name; 184 184 } -
src/wp-includes/option.php
841 841 842 842 $settings = (string) get_user_option( 'user-settings', $user_id ); 843 843 844 if ( isset( $_COOKIE[ 'wp-settings-' . $user_id] ) ) {845 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id] );844 if ( isset( $_COOKIE[ SETTINGS_COOKIE . $user_id ] ) ) { 845 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ SETTINGS_COOKIE . $user_id ] ); 846 846 847 847 // No change or both empty 848 848 if ( $cookie == $settings ) 849 849 return; 850 850 851 851 $last_saved = (int) get_user_option( 'user-settings-time', $user_id ); 852 $current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user_id] ) : 0;852 $current = isset( $_COOKIE[ SETTINGS_TIME_COOKIE . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ SETTINGS_TIME_COOKIE . $user_id ] ) : 0; 853 853 854 854 // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is 855 855 if ( $current > $last_saved ) { … … 861 861 862 862 // The cookie is not set in the current browser or the saved value is newer. 863 863 $secure = ( 'https' === parse_url( admin_url(), PHP_URL_SCHEME ) ); 864 setcookie( 'wp-settings-'. $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );865 setcookie( 'wp-settings-time-'. $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );866 $_COOKIE[ 'wp-settings-' . $user_id] = $settings;864 setcookie( SETTINGS_COOKIE . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure ); 865 setcookie( SETTINGS_TIME_COOKIE . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure ); 866 $_COOKIE[ SETTINGS_COOKIE . $user_id ] = $settings; 867 867 } 868 868 869 869 /** … … 962 962 963 963 $user_settings = array(); 964 964 965 if ( isset( $_COOKIE[ 'wp-settings-' . $user_id] ) ) {966 $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id] );965 if ( isset( $_COOKIE[ SETTINGS_COOKIE . $user_id ] ) ) { 966 $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ SETTINGS_COOKIE . $user_id ] ); 967 967 968 968 if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char 969 969 parse_str( $cookie, $user_settings ); … … 1033 1033 } 1034 1034 1035 1035 update_user_option( $user_id, 'user-settings', '', false ); 1036 setcookie( 'wp-settings-'. $user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );1036 setcookie( SETTINGS_COOKIE . $user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); 1037 1037 } 1038 1038 1039 1039 /** -
src/wp-includes/pluggable.php
953 953 setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 954 954 955 955 // Settings cookies 956 setcookie( 'wp-settings-'. get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );957 setcookie( 'wp-settings-time-'. get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );956 setcookie( SETTINGS_COOKIE . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); 957 setcookie( SETTINGS_TIME_COOKIE . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); 958 958 959 959 // Old cookies 960 960 setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); -
src/wp-includes/script-loader.php
73 73 'uid' => (string) get_current_user_id(), 74 74 'time' => (string) time(), 75 75 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ), 76 'settingsCookie' => (string) SETTINGS_COOKIE, 77 'settingsTimeCookie' => (string) SETTINGS_TIME_COOKIE, 76 78 ) ); 77 79 78 80 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );