Skip to content

Commit

Permalink
fix: setcookie() $value must be string in Gutenberg_HTTP_Signaling_Se…
Browse files Browse the repository at this point in the history
…rver::handle_read_pending_messages() (WordPress#68411)

Use strings instead of integers for `signaling_server_retries`, since cookies are sent as strings.

Co-authored-by: justlevine <justlevine@git.wordpress.org>
  • Loading branch information
justlevine and justlevine authored Jan 27, 2025
1 parent b984ec9 commit ad937ab
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private static function handle_read_pending_messages( $subscriber_to_messages_pa
if ( ! $fd ) {
$retries = isset( $_COOKIE['signaling_server_retries'] ) ? intval( $_COOKIE['signaling_server_retries'] ) : 0;
$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
setcookie( 'signaling_server_retries', $retries + 1, time() + DAY_IN_SECONDS, SITECOOKIEPATH, '', $secure );
setcookie( 'signaling_server_retries', (string) ( $retries + 1 ), time() + DAY_IN_SECONDS, SITECOOKIEPATH, '', $secure );
echo 'id: ' . time() . PHP_EOL;
echo 'event: error' . PHP_EOL;
echo 'data: ' . 'Could not open required file.' . PHP_EOL . PHP_EOL;
Expand All @@ -183,7 +183,7 @@ private static function handle_read_pending_messages( $subscriber_to_messages_pa
if ( isset( $_COOKIE['signaling_server_retries'] ) ) {
$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
// unset the cookie using a past expiration date.
setcookie( 'signaling_server_retries', 0, time() - DAY_IN_SECONDS, SITECOOKIEPATH, '', $secure );
setcookie( 'signaling_server_retries', '0', time() - DAY_IN_SECONDS, SITECOOKIEPATH, '', $secure );
}

echo 'retry: 3000' . PHP_EOL;
Expand Down

0 comments on commit ad937ab

Please sign in to comment.