[wp-trac] [WordPress Trac] #58566: WP_Http::normalize_cookies does not convert cookie names to strings
WordPress Trac
noreply at wordpress.org
Thu Sep 21 09:23:30 UTC 2023
#58566: WP_Http::normalize_cookies does not convert cookie names to strings
--------------------------+------------------------------
Reporter: nosilver4u | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTTP API | Version: 6.2.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by engahmeds3ed):
To add more context here, plz check this PHP core feature/bug :) here:
https://github.com/php/php-src/issues/9029
So if we even try to cast the cookie key to be string, this won't happen
because PHP will detect that this key is numeric and change it back to
integer so the error will occur in all cases.
I used the following code:
{{{#!php
<?php
add_filter( 'http_request_args', function( $args ){
if ( empty( $args['cookies'] ) || ! is_array( $args['cookies'] ) ) {
return $args;
}
foreach ( $args['cookies'] as $cookie_key => $cookie_value ) {
if ( is_string( $cookie_key ) ) {
continue;
}
unset( $args['cookies'][$cookie_key] );
}
return $args;
}, 1000 );
}}}
Just to remove the integer cookie keys not to fall in this WP fatal error
trap :)
Can we simply remove the thrown exception from here:
https://github.com/WordPress/wordpress-
develop/blob/b6b6ded79a54535b9ea80ae9c395dfa90262a4f9/src/wp-
includes/Requests/src/Cookie.php#L83-L85
What do u think?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58566#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list