Make WordPress Core

Ticket #46882: 46882.diff

File 46882.diff, 3.9 KB (added by TimothyBlynJacobs, 7 years ago)
  • src/wp-includes/class-wp-recovery-mode-cookie-service.php

    diff --git a/src/wp-includes/class-wp-recovery-mode-cookie-service.php b/src/wp-includes/class-wp-recovery-mode-cookie-service.php
    index c42dbb105c..eed4839cb4 100644
    a b  
    1313 */
    1414final class WP_Recovery_Mode_Cookie_Service {
    1515
    16         /**
    17          * The cookie name to use.
    18          *
    19          * @since 5.2.0
    20          * @var string
    21          */
    22         private $name;
    23 
    24         /**
    25          * The domain the cookie should be set on, {@see setcookie()}.
    26          *
    27          * @since 5.2.0
    28          * @var string
    29          */
    30         private $domain;
    31 
    32         /**
    33          * The path to limit the cookie to, {@see setcookie()}.
    34          *
    35          * @since 5.2.0
    36          * @var string
    37          */
    38         private $path;
    39 
    40         /**
    41          * The path to use when the home_url and site_url are different.
    42          *
    43          * @since 5.2.0
    44          * @var string
    45          */
    46         private $site_path;
    47 
    48         /**
    49          * WP_Recovery_Mode_Cookie_Service constructor.
    50          *
    51          * @since 5.2.0
    52          *
    53          * @param array $opts {
    54          *     Recovery mode cookie options.
    55          *
    56          *     @type string $name      Cookie name.
    57          *     @type string $domain    Cookie domain.
    58          *     @type string $path      Cookie path.
    59          *     @type string $site_path Site cookie path.
    60          * }
    61          */
    62         public function __construct( array $opts = array() ) {
    63                 $opts = wp_parse_args(
    64                         $opts,
    65                         array(
    66                                 'name'      => RECOVERY_MODE_COOKIE,
    67                                 'domain'    => COOKIE_DOMAIN,
    68                                 'path'      => COOKIEPATH,
    69                                 'site_path' => SITECOOKIEPATH,
    70                         )
    71                 );
    72 
    73                 $this->name      = $opts['name'];
    74                 $this->domain    = $opts['domain'];
    75                 $this->path      = $opts['path'];
    76                 $this->site_path = $opts['site_path'];
    77         }
    78 
    7916        /**
    8017         * Checks whether the recovery mode cookie is set.
    8118         *
    final class WP_Recovery_Mode_Cookie_Service { 
    8421         * @return bool True if the cookie is set, false otherwise.
    8522         */
    8623        public function is_cookie_set() {
    87                 return ! empty( $_COOKIE[ $this->name ] );
     24                return ! empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] );
    8825        }
    8926
    9027        /**
    final class WP_Recovery_Mode_Cookie_Service { 
    9835
    9936                $value = $this->generate_cookie();
    10037
    101                 setcookie( $this->name, $value, 0, $this->path, $this->domain, is_ssl(), true );
     38                setcookie( RECOVERY_MODE_COOKIE, $value, 0, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
    10239
    103                 if ( $this->path !== $this->site_path ) {
    104                         setcookie( $this->name, $value, 0, $this->site_path, $this->domain, is_ssl(), true );
     40                if ( COOKIEPATH !== SITECOOKIEPATH ) {
     41                        setcookie( RECOVERY_MODE_COOKIE, $value, 0, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
    10542                }
    10643        }
    10744
    final class WP_Recovery_Mode_Cookie_Service { 
    11148         * @since 5.2.0
    11249         */
    11350        public function clear_cookie() {
    114                 setcookie( $this->name, ' ', time() - YEAR_IN_SECONDS, $this->path, $this->domain );
    115                 setcookie( $this->name, ' ', time() - YEAR_IN_SECONDS, $this->site_path, $this->domain );
     51                setcookie( RECOVERY_MODE_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
     52                setcookie( RECOVERY_MODE_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
    11653        }
    11754
    11855        /**
    final class WP_Recovery_Mode_Cookie_Service { 
    12764        public function validate_cookie( $cookie = '' ) {
    12865
    12966                if ( ! $cookie ) {
    130                         if ( empty( $_COOKIE[ $this->name ] ) ) {
     67                        if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) {
    13168                                return new WP_Error( 'no_cookie', __( 'No cookie present.' ) );
    13269                        }
    13370
    134                         $cookie = $_COOKIE[ $this->name ];
     71                        $cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ];
    13572                }
    13673
    13774                $parts = $this->parse_cookie( $cookie );
    final class WP_Recovery_Mode_Cookie_Service { 
    182119         */
    183120        public function get_session_id_from_cookie( $cookie = '' ) {
    184121                if ( ! $cookie ) {
    185                         if ( empty( $_COOKIE[ $this->name ] ) ) {
     122                        if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) {
    186123                                return new WP_Error( 'no_cookie', __( 'No cookie present.' ) );
    187124                        }
    188125
    189                         $cookie = $_COOKIE[ $this->name ];
     126                        $cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ];
    190127                }
    191128
    192129                $parts = $this->parse_cookie( $cookie );