@@ -1613,20 +1613,27 @@ private function get_updates( $assoc_args ) {
16131613 // Reset error tracking
16141614 $ this ->version_check_error = null ;
16151615
1616- // Hook into pre_http_request with max priority to capture errors during version check
1617- // This is necessary because tests and plugins may use pre_http_request to mock responses
1618- add_filter ( 'pre_http_request ' , [ $ this , 'capture_version_check_error ' ], PHP_INT_MAX , 3 );
1616+ // Using closures so that the methods can stay private and aren't accidentally exposed as commands.
16191617
1620- // Also hook into http_api_debug to capture errors from real HTTP requests
1621- // This fires when pre_http_request doesn't short-circuit the request
1622- add_action ( 'http_api_debug ' , [ $ this , 'capture_version_check_error_from_response ' ], 10 , 5 );
1618+ $ capture_version_check_error = function ( $ response , $ args , $ url ) {
1619+ return $ this ->capture_version_check_error ( $ response , $ args , $ url );
1620+ };
1621+
1622+ $ capture_version_check_error_from_response = function ( $ response , $ context , $ _class , $ args , $ url ) {
1623+ return $ this ->capture_version_check_error_from_response ( $ response , $ context , $ _class , $ args , $ url );
1624+ };
1625+
1626+ add_filter ( 'pre_http_request ' , $ capture_version_check_error , PHP_INT_MAX , 3 );
1627+
1628+ // This fires when pre_http_request doesn't short-circuit the request.
1629+ add_action ( 'http_api_debug ' , $ capture_version_check_error_from_response , 10 , 5 );
16231630
16241631 try {
16251632 wp_version_check ( [], $ force_check );
16261633 } finally {
16271634 // Ensure the hooks are always removed, even if wp_version_check() throws an exception
1628- remove_filter ( 'pre_http_request ' , [ $ this , ' capture_version_check_error ' ] , PHP_INT_MAX );
1629- remove_action ( 'http_api_debug ' , [ $ this , ' capture_version_check_error_from_response ' ] , 10 );
1635+ remove_filter ( 'pre_http_request ' , $ capture_version_check_error , PHP_INT_MAX );
1636+ remove_action ( 'http_api_debug ' , $ capture_version_check_error_from_response , 10 );
16301637 }
16311638
16321639 /**
@@ -1727,7 +1734,7 @@ private function set_version_check_error( $response ) {
17271734 *
17281735 * @phpstan-param HTTP_Response|WP_Error|false $response
17291736 */
1730- public function capture_version_check_error ( $ response , $ args , $ url ) {
1737+ private function capture_version_check_error ( $ response , $ args , $ url ) {
17311738 if ( false === strpos ( $ url , 'api.wordpress.org/core/version-check ' ) ) {
17321739 return $ response ;
17331740 }
@@ -1756,7 +1763,7 @@ public function capture_version_check_error( $response, $args, $url ) {
17561763 *
17571764 * @phpstan-param HTTP_Response|WP_Error $response
17581765 */
1759- public function capture_version_check_error_from_response ( $ response , $ context , $ _class , $ _args , $ url ) {
1766+ private function capture_version_check_error_from_response ( $ response , $ context , $ _class , $ _args , $ url ) {
17601767 if ( false === strpos ( $ url , 'api.wordpress.org/core/version-check ' ) ) {
17611768 return ;
17621769 }
0 commit comments