Make WordPress Core


Ignore:
Timestamp:
03/10/2017 03:05:36 PM (8 years ago)
Author:
johnbillion
Message:

Build/Test tools: Don't override the wp_set_auth_cookie() and wp_clear_auth_cookie() functions.

Overriding pluggable functions in the test suite is asking for trouble in the future. In addition, it means the test suite can't be guaranteed to behave the same as core.

This instead introduces a send_auth_cookies filter which can be hooked in during the test suite to prevent these functions from attempting to send cookie headers to the client.

Fixes #39367

Merges [40263] and [40264] to the 4.7 branch.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/pluggable.php

    r40184 r40265  
    891891    do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
    892892
     893    /**
     894     * Allows preventing auth cookies from actually being sent to the client.
     895     *
     896     * @since 4.7.4
     897     *
     898     * @param bool $send Whether to send auth cookies to the client.
     899     */
     900    if ( ! apply_filters( 'send_auth_cookies', true ) ) {
     901        return;
     902    }
     903
    893904    setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
    894905    setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
     
    912923     */
    913924    do_action( 'clear_auth_cookie' );
     925
     926    /** This filter is documented in wp-includes/pluggable.php */
     927    if ( ! apply_filters( 'send_auth_cookies', true ) ) {
     928        return;
     929    }
    914930
    915931    setcookie( AUTH_COOKIE,        ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH,   COOKIE_DOMAIN );
Note: See TracChangeset for help on using the changeset viewer.