mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
External Libraries: Update the Requests library to version 2.0.0.
This is a major release and contains breaking changes. Most important changes to be aware of for this release: * All code is now namespaced. Though there is a full backward compatibility layer available and the old class names are still supported, using them will generate a deprecation notice (which can be silenced by plugins if they'd need to support multiple WP versions). See the [https://requests.ryanmccue.info/docs/upgrading.html upgrade guide] for more details. * A lot of classes have been marked `final`. This should generally not affect userland code as care has been taken to not apply the `final` keyword to classes which are known to be extended in userland code. * Extensive input validation has been added to Requests. When Requests is used as documented though, this will be unnoticable. * A new `WpOrg\Requests\Requests::has_capabilities()` method has been introduced which can be used to address #37708. * A new `WpOrg\Requests\Response::decode_body()` method has been introduced which may be usable to simplify some of the WP native wrapper code. * Remaining PHP 8.0 compatibility fixed (support for named parameters). * PHP 8.1 compatibility. Release notes: https://github.com/WordPress/Requests/releases/tag/v2.0.0 For a full list of changes in this update, see the Requests GitHub: https://github.com/WordPress/Requests/compare/v1.8.1...v2.0.0 Follow-up to [50842], [51078]. Props jrf, schlessera, datagutten, wojsmol, dd32, dustinrue, soulseekah, costdev, szepeviktor. Fixes #54504. git-svn-id: https://develop.svn.wordpress.org/trunk@52244 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -85,7 +85,7 @@ class Tests_Feed_wpSimplePieFile extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
return array(
|
||||
'headers' => new Requests_Utility_CaseInsensitiveDictionary( $single_value_headers ),
|
||||
'headers' => new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $single_value_headers ),
|
||||
'body' => file_get_contents( DIR_TESTDATA . '/feed/wordpress-org-news.xml' ),
|
||||
'response' => array(
|
||||
'code' => 200,
|
||||
@@ -114,7 +114,7 @@ class Tests_Feed_wpSimplePieFile extends WP_UnitTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
$response['headers'] = new Requests_Utility_CaseInsensitiveDictionary( $multiple_value_headers );
|
||||
$response['headers'] = new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $multiple_value_headers );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -364,9 +364,9 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_deserialize_request_utility_filtered_iterator_objects( $value ) {
|
||||
$serialized = maybe_serialize( $value );
|
||||
if ( get_class( $value ) === 'Requests_Utility_FilteredIterator' ) {
|
||||
if ( get_class( $value ) === 'WpOrg\Requests\Utility\FilteredIterator' ) {
|
||||
$new_value = unserialize( $serialized );
|
||||
$property = ( new ReflectionClass( 'Requests_Utility_FilteredIterator' ) )->getProperty( 'callback' );
|
||||
$property = ( new ReflectionClass( 'WpOrg\Requests\Utility\FilteredIterator' ) )->getProperty( 'callback' );
|
||||
$property->setAccessible( true );
|
||||
$callback_value = $property->getValue( $new_value );
|
||||
$this->assertSame( null, $callback_value );
|
||||
@@ -377,8 +377,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
public function data_serialize_deserialize_objects() {
|
||||
return array(
|
||||
array( new Requests_Utility_FilteredIterator( array( 1 ), 'md5' ) ),
|
||||
array( new Requests_Utility_FilteredIterator( array( 1, 2 ), 'sha1' ) ),
|
||||
array( new WpOrg\Requests\Utility\FilteredIterator( array( 1 ), 'md5' ) ),
|
||||
array( new WpOrg\Requests\Utility\FilteredIterator( array( 1, 2 ), 'sha1' ) ),
|
||||
array( new ArrayIterator( array( 1, 2, 3 ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_get_cookie_host_only() {
|
||||
// Emulate WP_Http::request() internals.
|
||||
$requests_response = new Requests_Response();
|
||||
$requests_response = new WpOrg\Requests\Response();
|
||||
|
||||
$requests_response->cookies['test'] = Requests_Cookie::parse( 'test=foo; domain=.wordpress.org' );
|
||||
$requests_response->cookies['test'] = WpOrg\Requests\Cookie::parse( 'test=foo; domain=.wordpress.org' );
|
||||
|
||||
$requests_response->cookies['test']->flags['host-only'] = false; // https://github.com/WordPress/Requests/issues/306
|
||||
|
||||
@@ -231,7 +231,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase {
|
||||
$this->assertSame( $cookie->domain, 'wordpress.org' );
|
||||
$this->assertFalse( $cookie->host_only, 'host-only flag not set' );
|
||||
|
||||
// Regurgitate (Requests_Cookie -> WP_Http_Cookie -> Requests_Cookie).
|
||||
// Regurgitate (WpOrg\Requests\Cookie -> WP_Http_Cookie -> WpOrg\Requests\Cookie).
|
||||
$cookies = WP_Http::normalize_cookies( wp_remote_retrieve_cookies( $response ) );
|
||||
$this->assertFalse( $cookies['test']->flags['host-only'], 'host-only flag data lost' );
|
||||
}
|
||||
|
||||
@@ -309,13 +309,13 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertInstanceOf( 'Requests_Cookie_Jar', $cookie_jar );
|
||||
$this->assertInstanceOf( 'WpOrg\Requests\Cookie\Jar', $cookie_jar );
|
||||
|
||||
foreach ( array_keys( $cookies ) as $cookie ) {
|
||||
if ( 'foo' === $cookie ) {
|
||||
$this->assertArrayNotHasKey( $cookie, $cookie_jar );
|
||||
} else {
|
||||
$this->assertInstanceOf( 'Requests_Cookie', $cookie_jar[ $cookie ] );
|
||||
$this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar[ $cookie ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
);
|
||||
|
||||
return array(
|
||||
'headers' => new Requests_Utility_CaseInsensitiveDictionary( $single_value_headers ),
|
||||
'headers' => new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $single_value_headers ),
|
||||
'body' => file_get_contents( DIR_TESTDATA . '/feed/wordpress-org-news.xml' ),
|
||||
'response' => array(
|
||||
'code' => 200,
|
||||
|
||||
@@ -65,7 +65,7 @@ class Tests_REST_WpRestBlockNavigationAreasController extends WP_Test_REST_Contr
|
||||
|
||||
public function test_context_param() {
|
||||
wp_set_current_user( static::$admin_id );
|
||||
$request = new WP_REST_Request( Requests::OPTIONS, '/wp/v2/block-navigation-areas' );
|
||||
$request = new WP_REST_Request( WpOrg\Requests\Requests::OPTIONS, '/wp/v2/block-navigation-areas' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
$data = $response->get_data();
|
||||
@@ -101,7 +101,7 @@ class Tests_REST_WpRestBlockNavigationAreasController extends WP_Test_REST_Contr
|
||||
wp_set_current_user( static::$admin_id );
|
||||
$navigation_area = array_rand( get_navigation_areas(), 1 );
|
||||
$route = sprintf( '/wp/v2/block-navigation-areas/%s', urlencode( $navigation_area ) );
|
||||
$request = new WP_REST_Request( Requests::POST, $route );
|
||||
$request = new WP_REST_Request( WpOrg\Requests\Requests::POST, $route );
|
||||
|
||||
$updated_navigation_area = array(
|
||||
'name' => $navigation_area,
|
||||
|
||||
@@ -106,7 +106,7 @@ class Tests_Widgets_wpWidgetRss extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
return array(
|
||||
'headers' => new Requests_Utility_CaseInsensitiveDictionary( $single_value_headers ),
|
||||
'headers' => new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $single_value_headers ),
|
||||
'body' => file_get_contents( DIR_TESTDATA . '/feed/wordpress-org-news.xml' ),
|
||||
'response' => array(
|
||||
'code' => 200,
|
||||
|
||||
Reference in New Issue
Block a user