WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#37768 closed defect (bug) (fixed)

HTTP API No Longer Accepts Integer and Float Values for the 'cookies' Argument since v4.6

Reported by: miunosoft Owned by: swissspidy
Milestone: 4.6.1 Priority: normal
Severity: normal Version: 4.6
Component: HTTP API Keywords: has-patch has-unit-tests fixed-major
Focuses: Cc:

Description

It seems integer and float values set to the cookies argument of wp_remote_get() and wp_remote_post() get lost with v4.6.

wp_remote_get(
    $request_url,   
    array(          
        'timeout'       => 0.01, 
        'blocking'      => false,
        'cookies'       => array(
            'x' => 'foo', // Okay
            'y' => 2,     // disappears
            'z' => 0.45', // disappears
        ),
    ) 
);

Attachments (1)

37768.diff (1.7 KB) - added by swissspidy 3 years ago.

Download all attachments as: .zip

Change History (11)

#1 @miunosoft
3 years ago

  • Summary changed from HTTP API No Longer Accepts Integer and Float Values since v4.6 to HTTP API No Longer Accepts Integer and Float Values for the 'cookies' Argument since v4.6

#2 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 4.6.1

#3 follow-up: @swissspidy
3 years ago

@miunosoft Is 'z' => 0.45' simply a typo when posting here in trac?

This ticket was mentioned in Slack in #core by jeremyfelt. View the logs.


3 years ago

#5 @swissspidy
3 years ago

  • Owner set to swissspidy
  • Status changed from new to assigned

#6 in reply to: ↑ 3 @miunosoft
3 years ago

Replying to swissspidy:

@miunosoft Is 'z' => 0.45' simply a typo when posting here in trac?

@swissspidy Indeed, that was a typo. Sorry.

@swissspidy
3 years ago

#7 @swissspidy
3 years ago

  • Keywords has-patch has-unit-tests added

WP_Http::normalize_cookies() only checks for values that are instances of WP_Http_Cookie and strings. Any other scalar value gets ignored. That method was introduced in 4.6 so something definitely changed there.

37768.diff changes this by casting scalars to strings.

@dd32 @rmccue As I am not that familiar with the HTTP API, I'd love to hear your opinion on this.

#8 @dd32
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 38430:

HTTP: Accept non-string values in cookies, fixing a regression since 4.5.

Props swissspidy.
Fixes #37768 for trunk.

#9 @dd32
3 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#10 @dd32
3 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 38461:

HTTP: Accept non-string values in cookies, fixing a regression since 4.5.

Props swissspidy.
Merges [38430] to the 4.6 branch.
Fixes #37768.

Note: See TracTickets for help on using tickets.