Skip to content

Instantly share code, notes, and snippets.

@ironprogrammer
Created December 9, 2022 00:32
Show Gist options
  • Save ironprogrammer/35a762d0100a7a01f4eadc37ee6b16cd to your computer and use it in GitHub Desktop.
Save ironprogrammer/35a762d0100a7a01f4eadc37ee6b16cd to your computer and use it in GitHub Desktop.
Optional logging for testing Requests PR 3732
diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php
index 3b411e0c47..d589d06fe8 100644
--- a/src/wp-admin/includes/update-core.php
+++ b/src/wp-admin/includes/update-core.php
@@ -1032,6 +1032,7 @@ function update_core( $from, $to ) {
set_time_limit( 300 );
_preload_old_requests_files( $to );
+ _test_pr_3732();
/**
* Filters feedback messages displayed during the core update process.
@@ -1580,6 +1581,81 @@ function _preload_old_requests_files( $to ) {
}
}
+function _test_pr_3732() {
+ // Interfaces.
+ $old_requests_interfaces = array(
+ 'requests_auth',
+ 'requests_hooker',
+ 'requests_proxy',
+ 'requests_transport',
+ );
+
+ // Classes.
+ $old_requests_classes = array(
+ 'requests_cookie',
+ 'requests_exception',
+ 'requests_hooks',
+ 'requests_idnaencoder',
+ 'requests_ipv6',
+ 'requests_iri',
+ 'requests_response',
+ 'requests_session',
+ 'requests_ssl',
+ 'requests_auth_basic',
+ 'requests_cookie_jar',
+ 'requests_proxy_http',
+ 'requests_response_headers',
+ 'requests_transport_curl',
+ 'requests_transport_fsockopen',
+ 'requests_utility_caseinsensitivedictionary',
+ 'requests_utility_filterediterator',
+ 'requests_exception_http',
+ 'requests_exception_transport',
+ 'requests_exception_transport_curl',
+ 'requests_exception_http_304',
+ 'requests_exception_http_305',
+ 'requests_exception_http_306',
+ 'requests_exception_http_400',
+ 'requests_exception_http_401',
+ 'requests_exception_http_402',
+ 'requests_exception_http_403',
+ 'requests_exception_http_404',
+ 'requests_exception_http_405',
+ 'requests_exception_http_406',
+ 'requests_exception_http_407',
+ 'requests_exception_http_408',
+ 'requests_exception_http_409',
+ 'requests_exception_http_410',
+ 'requests_exception_http_411',
+ 'requests_exception_http_412',
+ 'requests_exception_http_413',
+ 'requests_exception_http_414',
+ 'requests_exception_http_415',
+ 'requests_exception_http_416',
+ 'requests_exception_http_417',
+ 'requests_exception_http_418',
+ 'requests_exception_http_428',
+ 'requests_exception_http_429',
+ 'requests_exception_http_431',
+ 'requests_exception_http_500',
+ 'requests_exception_http_501',
+ 'requests_exception_http_502',
+ 'requests_exception_http_503',
+ 'requests_exception_http_504',
+ 'requests_exception_http_505',
+ 'requests_exception_http_511',
+ 'requests_exception_http_unknown',
+ );
+
+ foreach ( $old_requests_interfaces as $requests_interface ) {
+ error_log( interface_exists( $requests_interface ) ? "{$requests_interface} was preloaded." : "{$requests_interface} was not preloaded." );
+ }
+
+ foreach ( $old_requests_classes as $requests_class ) {
+ error_log( class_exists( $requests_class ) ? "{$requests_class} was preloaded." : "{$requests_class} was not preloaded." );
+ }
+}
+
/**
* Redirect to the About WordPress page after a successful upgrade.
*
@ironprogrammer
Copy link
Author

Requests 1.x -> 2.0 Preload Logger

This patch applies optional logging to wp-admin/includes/update_core.php, referenced at the end of the PR 3732 testing instructions. Also see Trac 54504 and PR 3732.

It's recommended that this patch be applied in the same location as the PR, and then copied over along with the PR files when creating the custom package. ☝🏻 Note that this file is separate from the PR's wp-includes/ changes, and must be copied separately.

Finally, check that WP_DEBUG and WP_DEBUG_LOG are enabled before proceeding with the upgrade test.

Expected Output

There should be 57 lines (one for each old Requests 1.x interface and class) logged during the upgrade, and each line should end with "was preloaded" ✅. For example:

[09-Dec-2022 00:02:10 UTC] requests_auth was preloaded.
[09-Dec-2022 00:02:10 UTC] requests_hooker was preloaded.
[09-Dec-2022 00:02:10 UTC] requests_proxy was preloaded.
...

Props @costdev for the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment