Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#13730 closed defect (bug) (fixed)

http_request() fails when passed an array for the $body parameter

Reported by: mdawaffe's profile mdawaffe Owned by: westi's profile westi
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0
Component: HTTP API Keywords: has-patch commit
Focuses: Cc:

Description

Passing an empty array to WP_Http::request in the body argument causes an error if the WP_Http_ExtHTTP transport is used:

WP_Http::request( $url, array( 'body' => array() ) );

Since the body is empty, it gets ignored and so does not get converted into a (string) http query; it's passed straight into

@http_request($r['method'], $url, $r['body'], $options, $info);

Which causes an error.

Attached sets empty bodies to the default (null).

Attachments (1)

13730.diff (564 bytes) - added by mdawaffe 14 years ago.

Download all attachments as: .zip

Change History (6)

@mdawaffe
14 years ago

#1 follow-up: @westi
14 years ago

  • Component changed from General to HTTP
  • Milestone changed from Unassigned to 3.1
  • Owner set to westi
  • Status changed from new to reviewing
  • Version set to 3.0

That looks sane.

Is this bug triggered by any core code or a popular plugin?

#2 @mdawaffe
14 years ago

Thanks for fixing the component/version.

It's triggered by a plugin I'm writing :)

I honestly don't know how often people will run into this bug because the HTTP extension is rarely installed. When it is installed, though, it's the preferred transport.

So it's possible a small number of people will get hit with this bug constantly and silently because of the error suppression on http://core.trac.wordpress.org/browser/trunk/wp-includes/class-http.php?rev=15144#L1216

#3 in reply to: ↑ 1 @mdawaffe
14 years ago

Replying to westi:

Is this bug triggered by any core code or a popular plugin?

I can find no chance of this occurring in core.

#4 @nacin
14 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Triage to 3.1

#5 @nacin
14 years ago

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

(In [16450]) WP_Http_ExtHTTP variable fix. Don't pass an empty array to http_request, props mdawaffe, fixes #13730.

Note: See TracTickets for help on using tickets.