WordPress.org

Make WordPress Core

Ticket #35188: 35188-2.patch

File 35188-2.patch, 1.6 KB (added by dwainm, 4 years ago)

Updated doc blocks and added argument to wp_create_nonce function call to wp_nonce_tick call

  • src/wp-includes/pluggable.php

     
    17891789 *
    17901790 * @since 2.5.0
    17911791 *
     1792 * @param string|int $action the current action.
     1793 *
    17921794 * @return float Float value rounded up to the next highest integer.
    17931795 */
    1794 function wp_nonce_tick() {
    1795         /**
    1796          * Filter the lifespan of nonces in seconds.
    1797          *
    1798          * @since 2.5.0
    1799          *
    1800          * @param int $lifespan Lifespan of nonces in seconds. Default 86,400 seconds, or one day.
    1801          */
    1802         $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS );
     1796function wp_nonce_tick( $action = -1 ) {
     1797    /**
     1798     * Filter the lifespan of nonces in seconds.
     1799     *
     1800     * @since 2.5.0
     1801     *
     1802     * @param int $lifespan Lifespan of nonces in seconds. Default 86,400 seconds, or one day.
     1803     * @param string|int $action The current nonce.
     1804     */
     1805    $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action );
    18031806
    1804         return ceil(time() / ( $nonce_life / 2 ));
     1807    return ceil( time() / ( $nonce_life / 2 ) );
    18051808}
    18061809endif;
    18071810
     
    18401843        }
    18411844
    18421845        $token = wp_get_session_token();
    1843         $i = wp_nonce_tick();
     1846        $i = wp_nonce_tick( $action );
    18441847
    18451848        // Nonce generated 0-12 hours ago
    18461849        $expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10 );
     
    18911894        }
    18921895
    18931896        $token = wp_get_session_token();
    1894         $i = wp_nonce_tick();
     1897        $i = wp_nonce_tick( $action );
    18951898
    18961899        return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
    18971900}