Skip to content

Commit e73db80

Browse files
committed
External Libraries: Update the Requests library to version 2.0.11.
This is a maintenance release with two minor fixes to improve PHP 8.4 compatibility. References: - [https://github.com/WordPress/Requests/releases/tag/v2.0.11 Requests 2.0.11 release notes] - [WordPress/Requests@v2.0.9...v2.0.11 Full list of changes in Requests 2.0.11] Follow-up to [56554], [54997], [55007], [55046], [55225], [55296], [55629]. Props swissspidy, jrf. Fixes #60838. git-svn-id: https://develop.svn.wordpress.org/trunk@57876 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f9b59e9 commit e73db80

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/wp-includes/Requests/src/Cookie.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,19 @@ public static function parse($cookie_header, $name = '', $reference_time = null)
470470
* @param \WpOrg\Requests\Iri|null $origin URI for comparing cookie origins
471471
* @param int|null $time Reference time for expiration calculation
472472
* @return array
473+
*
474+
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $origin argument is not null or an instance of the Iri class.
473475
*/
474-
public static function parse_from_headers(Headers $headers, Iri $origin = null, $time = null) {
476+
public static function parse_from_headers(Headers $headers, $origin = null, $time = null) {
475477
$cookie_headers = $headers->getValues('Set-Cookie');
476478
if (empty($cookie_headers)) {
477479
return [];
478480
}
479481

482+
if ($origin !== null && !($origin instanceof Iri)) {
483+
throw InvalidArgument::create(2, '$origin', Iri::class . ' or null', gettype($origin));
484+
}
485+
480486
$cookies = [];
481487
foreach ($cookie_headers as $header) {
482488
$parsed = self::parse($header, '', $time);

src/wp-includes/Requests/src/Requests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class Requests {
148148
*
149149
* @var string
150150
*/
151-
const VERSION = '2.0.9';
151+
const VERSION = '2.0.11';
152152

153153
/**
154154
* Selected transport name

src/wp-includes/Requests/src/Transport/Fsockopen.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ public function request($url, $headers = [], $data = [], $options = []) {
144144
$verifyname = false;
145145
}
146146

147-
stream_context_set_option($context, ['ssl' => $context_options]);
147+
// Handle the PHP 8.4 deprecation (PHP 9.0 removal) of the function signature we use for stream_context_set_option().
148+
// Ref: https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#stream_context_set_option
149+
if (function_exists('stream_context_set_options')) {
150+
// PHP 8.3+.
151+
stream_context_set_options($context, ['ssl' => $context_options]);
152+
} else {
153+
// PHP < 8.3.
154+
stream_context_set_option($context, ['ssl' => $context_options]);
155+
}
148156
} else {
149157
$remote_socket = 'tcp://' . $host;
150158
}

0 commit comments

Comments
 (0)