From 7759f06d5fcc149f7329840531501bde75f3c9bd Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 17 Feb 2017 05:06:23 +0000 Subject: [PATCH] HTTP API: Restore backwards compatibility with the `http_api_curl` filter - it expects that the handle parameter is passed as a reference, however [39212] missed that. Props pento. Merges [40068] to the 4.7 branch. Fixes #39783. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40069 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-http-requests-hooks.php | 2 +- tests/phpunit/tests/http/curl.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-http-requests-hooks.php b/src/wp-includes/class-wp-http-requests-hooks.php index 108fae8c10..6650d5869c 100644 --- a/src/wp-includes/class-wp-http-requests-hooks.php +++ b/src/wp-includes/class-wp-http-requests-hooks.php @@ -54,7 +54,7 @@ class WP_HTTP_Requests_Hooks extends Requests_Hooks { switch ( $hook ) { case 'curl.before_send': /** This action is documented in wp-includes/class-wp-http-curl.php */ - do_action_ref_array( 'http_api_curl', array( $parameters[0], $this->request, $this->url ) ); + do_action_ref_array( 'http_api_curl', array( &$parameters[0], $this->request, $this->url ) ); break; } diff --git a/tests/phpunit/tests/http/curl.php b/tests/phpunit/tests/http/curl.php index b9481ed6cb..f3f80cd264 100644 --- a/tests/phpunit/tests/http/curl.php +++ b/tests/phpunit/tests/http/curl.php @@ -8,4 +8,19 @@ require_once dirname( __FILE__ ) . '/base.php'; */ class Tests_HTTP_curl extends WP_HTTP_UnitTestCase { var $transport = 'curl'; + + /** + * @ticket 39783 + */ + public function test_http_api_curl_stream_parameter_is_a_reference() { + add_action( 'http_api_curl', array( $this, '_action_test_http_api_curl_stream_parameter_is_a_reference' ), 10, 3 ); + wp_remote_request( $this->fileStreamUrl, array( 'stream' => true, 'timeout' => 30 ) ); + remove_action( 'http_api_curl', array( $this, '_action_test_http_api_curl_stream_parameter_is_a_reference' ), 10 ); + } + + public function _action_test_http_api_curl_stream_parameter_is_a_reference( &$stream, $r, $url ) { + // $stream not being a reference will cause a PHP warning. + // For counting tests purposes, let's do a fake assert. + $this->assertTrue( true ); + } }