From 55d05b56c3007a4da861aea0361641c14d4e6deb Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 17 Jun 2019 19:17:54 +0000 Subject: [PATCH] Bootstrap/Load: Set expiration of the recovery mode cookie to the same amount of time for which the token in it is valid: a week by default. Props david.binda, TimothyBlynJacobs. Fixes #47480. Built from https://develop.svn.wordpress.org/trunk@45545 git-svn-id: http://core.svn.wordpress.org/trunk@45356 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-recovery-mode-cookie-service.php | 22 +++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/wp-includes/class-wp-recovery-mode-cookie-service.php b/wp-includes/class-wp-recovery-mode-cookie-service.php index ebc62d0afd..ff042c5318 100644 --- a/wp-includes/class-wp-recovery-mode-cookie-service.php +++ b/wp-includes/class-wp-recovery-mode-cookie-service.php @@ -35,10 +35,20 @@ final class WP_Recovery_Mode_Cookie_Service { $value = $this->generate_cookie(); - setcookie( RECOVERY_MODE_COOKIE, $value, 0, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); + /** + * Filter the length of time a Recovery Mode cookie is valid for. + * + * @since 5.2.0 + * + * @param int $length Length in seconds. + */ + $length = apply_filters( 'recovery_mode_cookie_length', WEEK_IN_SECONDS ); + $expire = time() + $length; + + setcookie( RECOVERY_MODE_COOKIE, $value, $expire, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); if ( COOKIEPATH !== SITECOOKIEPATH ) { - setcookie( RECOVERY_MODE_COOKIE, $value, 0, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); + setcookie( RECOVERY_MODE_COOKIE, $value, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); } } @@ -83,13 +93,7 @@ final class WP_Recovery_Mode_Cookie_Service { return new WP_Error( 'invalid_created_at', __( 'Invalid cookie format.' ) ); } - /** - * Filter the length of time a Recovery Mode cookie is valid for. - * - * @since 5.2.0 - * - * @param int $length Length in seconds. - */ + /** This filter is documented in wp-includes/class-wp-recovery-mode-cookie-service.php */ $length = apply_filters( 'recovery_mode_cookie_length', WEEK_IN_SECONDS ); if ( time() > $created_at + $length ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 7b913f58c5..0a0571b74f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45544'; +$wp_version = '5.3-alpha-45545'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.