Skip to content

Commit d7dd42d

Browse files
External Libraries: Update 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: WordPress/Requests@v1.8.1...v2.0.0 This commit also resolves 2 blocking issues which previously caused the revert of [52244]: * New Requests files are loaded into `wp-includes/Requests/src/`, matching the location of the library. In doing so, filesystems that are case-insensitive are not impacted (see #54582). * Preload: During a Core update, the old Requests files are preloaded into memory before the update deletes the files. Preloading avoids fatal errors noted in #54562. Follow-up to [50842], [51078], [52244], [52315], [52327], [52328]. Props jrf, schlessera, datagutten, wojsmol, dustinrue, soulseekah, szepeviktor. costdev, sergeybiryukov, peterwilsoncc, ironprogrammer, antonvlasenko, hellofromTonya, swissspidy, dd32, azaozz, TobiasBg, audrasjb. Fixes #54504. See #54582, #54562. git-svn-id: https://develop.svn.wordpress.org/trunk@54997 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 98fd38f commit d7dd42d

File tree

91 files changed

+3977
-2540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3977
-2540
lines changed

src/wp-admin/includes/update-core.php

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,96 @@
865865
'wp-includes/blocks/comments-query-loop',
866866
);
867867

868+
/**
869+
* Stores Requests files to be preloaded and deleted.
870+
*
871+
* For classes/interfaces, use the class/interface name
872+
* as the array key.
873+
*
874+
* All other files/directories should not have a key.
875+
*
876+
* @since 6.2.0
877+
*
878+
* @global array $_old_requests_files
879+
* @var array
880+
* @name $_old_requests_files
881+
*/
882+
global $_old_requests_files;
883+
884+
$_old_requests_files = array(
885+
// Interfaces.
886+
'Requests_Auth' => 'wp-includes/Requests/Auth.php',
887+
'Requests_Hooker' => 'wp-includes/Requests/Hooker.php',
888+
'Requests_Proxy' => 'wp-includes/Requests/Proxy.php',
889+
'Requests_Transport' => 'wp-includes/Requests/Transport.php',
890+
891+
// Classes.
892+
'Requests_Auth_Basic' => 'wp-includes/Requests/Auth/Basic.php',
893+
'Requests_Cookie_Jar' => 'wp-includes/Requests/Cookie/Jar.php',
894+
'Requests_Exception_HTTP' => 'wp-includes/Requests/Exception/HTTP.php',
895+
'Requests_Exception_Transport' => 'wp-includes/Requests/Exception/Transport.php',
896+
'Requests_Exception_HTTP_304' => 'wp-includes/Requests/Exception/HTTP/304.php',
897+
'Requests_Exception_HTTP_305' => 'wp-includes/Requests/Exception/HTTP/305.php',
898+
'Requests_Exception_HTTP_306' => 'wp-includes/Requests/Exception/HTTP/306.php',
899+
'Requests_Exception_HTTP_400' => 'wp-includes/Requests/Exception/HTTP/400.php',
900+
'Requests_Exception_HTTP_401' => 'wp-includes/Requests/Exception/HTTP/401.php',
901+
'Requests_Exception_HTTP_402' => 'wp-includes/Requests/Exception/HTTP/402.php',
902+
'Requests_Exception_HTTP_403' => 'wp-includes/Requests/Exception/HTTP/403.php',
903+
'Requests_Exception_HTTP_404' => 'wp-includes/Requests/Exception/HTTP/404.php',
904+
'Requests_Exception_HTTP_405' => 'wp-includes/Requests/Exception/HTTP/405.php',
905+
'Requests_Exception_HTTP_406' => 'wp-includes/Requests/Exception/HTTP/406.php',
906+
'Requests_Exception_HTTP_407' => 'wp-includes/Requests/Exception/HTTP/407.php',
907+
'Requests_Exception_HTTP_408' => 'wp-includes/Requests/Exception/HTTP/408.php',
908+
'Requests_Exception_HTTP_409' => 'wp-includes/Requests/Exception/HTTP/409.php',
909+
'Requests_Exception_HTTP_410' => 'wp-includes/Requests/Exception/HTTP/410.php',
910+
'Requests_Exception_HTTP_411' => 'wp-includes/Requests/Exception/HTTP/411.php',
911+
'Requests_Exception_HTTP_412' => 'wp-includes/Requests/Exception/HTTP/412.php',
912+
'Requests_Exception_HTTP_413' => 'wp-includes/Requests/Exception/HTTP/413.php',
913+
'Requests_Exception_HTTP_414' => 'wp-includes/Requests/Exception/HTTP/414.php',
914+
'Requests_Exception_HTTP_415' => 'wp-includes/Requests/Exception/HTTP/415.php',
915+
'Requests_Exception_HTTP_416' => 'wp-includes/Requests/Exception/HTTP/416.php',
916+
'Requests_Exception_HTTP_417' => 'wp-includes/Requests/Exception/HTTP/417.php',
917+
'Requests_Exception_HTTP_418' => 'wp-includes/Requests/Exception/HTTP/418.php',
918+
'Requests_Exception_HTTP_428' => 'wp-includes/Requests/Exception/HTTP/428.php',
919+
'Requests_Exception_HTTP_429' => 'wp-includes/Requests/Exception/HTTP/429.php',
920+
'Requests_Exception_HTTP_431' => 'wp-includes/Requests/Exception/HTTP/431.php',
921+
'Requests_Exception_HTTP_500' => 'wp-includes/Requests/Exception/HTTP/500.php',
922+
'Requests_Exception_HTTP_501' => 'wp-includes/Requests/Exception/HTTP/501.php',
923+
'Requests_Exception_HTTP_502' => 'wp-includes/Requests/Exception/HTTP/502.php',
924+
'Requests_Exception_HTTP_503' => 'wp-includes/Requests/Exception/HTTP/503.php',
925+
'Requests_Exception_HTTP_504' => 'wp-includes/Requests/Exception/HTTP/504.php',
926+
'Requests_Exception_HTTP_505' => 'wp-includes/Requests/Exception/HTTP/505.php',
927+
'Requests_Exception_HTTP_511' => 'wp-includes/Requests/Exception/HTTP/511.php',
928+
'Requests_Exception_HTTP_Unknown' => 'wp-includes/Requests/Exception/HTTP/Unknown.php',
929+
'Requests_Exception_Transport_cURL' => 'wp-includes/Requests/Exception/Transport/cURL.php',
930+
'Requests_Proxy_HTTP' => 'wp-includes/Requests/Proxy/HTTP.php',
931+
'Requests_Response_Headers' => 'wp-includes/Requests/Response/Headers.php',
932+
'Requests_Transport_cURL' => 'wp-includes/Requests/Transport/cURL.php',
933+
'Requests_Transport_fsockopen' => 'wp-includes/Requests/Transport/fsockopen.php',
934+
'Requests_Utility_CaseInsensitiveDictionary' => 'wp-includes/Requests/Utility/CaseInsensitiveDictionary.php',
935+
'Requests_Utility_FilteredIterator' => 'wp-includes/Requests/Utility/FilteredIterator.php',
936+
'Requests_Cookie' => 'wp-includes/Requests/Cookie.php',
937+
'Requests_Exception' => 'wp-includes/Requests/Exception.php',
938+
'Requests_Hooks' => 'wp-includes/Requests/Hooks.php',
939+
'Requests_IDNAEncoder' => 'wp-includes/Requests/IDNAEncoder.php',
940+
'Requests_IPv6' => 'wp-includes/Requests/IPv6.php',
941+
'Requests_IRI' => 'wp-includes/Requests/IRI.php',
942+
'Requests_Response' => 'wp-includes/Requests/Response.php',
943+
'Requests_SSL' => 'wp-includes/Requests/SSL.php',
944+
'Requests_Session' => 'wp-includes/Requests/Session.php',
945+
946+
// Directories.
947+
'wp-includes/Requests/Auth/',
948+
'wp-includes/Requests/Cookie/',
949+
'wp-includes/Requests/Exception/HTTP/',
950+
'wp-includes/Requests/Exception/Transport/',
951+
'wp-includes/Requests/Exception/',
952+
'wp-includes/Requests/Proxy/',
953+
'wp-includes/Requests/Response/',
954+
'wp-includes/Requests/Transport/',
955+
'wp-includes/Requests/Utility/',
956+
);
957+
868958
/**
869959
* Stores new files in wp-content to copy
870960
*
@@ -949,6 +1039,7 @@
9491039
*
9501040
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
9511041
* @global array $_old_files
1042+
* @global array $_old_requests_files
9521043
* @global array $_new_bundled_files
9531044
* @global wpdb $wpdb WordPress database abstraction object.
9541045
* @global string $wp_version
@@ -960,10 +1051,18 @@
9601051
* @return string|WP_Error New WordPress version on success, WP_Error on failure.
9611052
*/
9621053
function update_core( $from, $to ) {
963-
global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
1054+
global $wp_filesystem, $_old_files, $_old_requests_files, $_new_bundled_files, $wpdb;
9641055

9651056
set_time_limit( 300 );
9661057

1058+
/*
1059+
* Merge the old Requests files and directories into the `$_old_files`.
1060+
* Then preload these Requests files first, before the files are deleted
1061+
* and replaced to ensure the code is in memory if needed.
1062+
*/
1063+
$_old_files = array_merge( $_old_files, array_values( $_old_requests_files ) );
1064+
_preload_old_requests_classes_and_interfaces( $to );
1065+
9671066
/**
9681067
* Filters feedback messages displayed during the core update process.
9691068
*
@@ -1478,6 +1577,48 @@ function update_core( $from, $to ) {
14781577
return $wp_version;
14791578
}
14801579

1580+
/**
1581+
* Preloads old Requests classes and interfaces.
1582+
*
1583+
* This function preloads the old Requests code into memory before the
1584+
* upgrade process deletes the files. Why? Requests code is loaded into
1585+
* memory via an autoloader, meaning when a class or interface is needed
1586+
* If a request is in process, Requests could attempt to access code. If
1587+
* the file is not there, a fatal error could occur. If the file was
1588+
* replaced, the new code is not compatible with the old, resulting in
1589+
* a fatal error. Preloading ensures the code is in memory before the
1590+
* code is updated.
1591+
*
1592+
* @since 6.2.0
1593+
*
1594+
* @global array $_old_requests_files Requests files to be preloaded.
1595+
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
1596+
*
1597+
* @param string $to Path to old WordPress installation.
1598+
*/
1599+
function _preload_old_requests_classes_and_interfaces( $to ) {
1600+
global $_old_requests_files, $wp_filesystem;
1601+
1602+
foreach ( $_old_requests_files as $name => $file ) {
1603+
// Skip files that aren't interfaces or classes.
1604+
if ( is_int( $name ) ) {
1605+
continue;
1606+
}
1607+
1608+
// Skip if it's already loaded.
1609+
if ( class_exists( $name ) || interface_exists( $name ) ) {
1610+
continue;
1611+
}
1612+
1613+
// Skip if the file is missing.
1614+
if ( ! $wp_filesystem->is_file( $to . $file ) ) {
1615+
continue;
1616+
}
1617+
1618+
require_once $to . $file;
1619+
}
1620+
}
1621+
14811622
/**
14821623
* Redirect to the About WordPress page after a successful upgrade.
14831624
*

src/wp-includes/Requests/Auth.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

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

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)