Skip to content

Commit

Permalink
Tests: Prevent wp_update_themes() from running in `wp_ajax_update_t…
Browse files Browse the repository at this point in the history
…heme()` tests.

In the tests for updating a theme via Ajax, `wp_installing( true )` is called to prevent `wp_update_themes()` from running.

This worked as expected in `test_update_theme()`, however, it was missed in `test_uppercase_theme_slug()`, which was accidentally relying on the `wp_installing()` status not being properly restored in the previous test.

Now that the `wp_installing()` status was corrected in [54723], the latter test started throwing an error on PHP 8.2:
{{{
1) Tests_Ajax_wpAjaxUpdateTheme::test_uppercase_theme_slug
http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated

/var/www/src/wp-includes/Requests/Transport/cURL.php:345
/var/www/src/wp-includes/Requests/Transport/cURL.php:135
/var/www/src/wp-includes/class-requests.php:381
/var/www/src/wp-includes/class-wp-http.php:395
/var/www/src/wp-includes/class-wp-http.php:615
/var/www/src/wp-includes/http.php:179
/var/www/src/wp-includes/update.php:719
/var/www/src/wp-admin/includes/ajax-actions.php:4292
/var/www/src/wp-includes/class-wp-hook.php:308
/var/www/src/wp-includes/class-wp-hook.php:332
/var/www/src/wp-includes/plugin.php:517
/var/www/tests/phpunit/includes/testcase-ajax.php:265
/var/www/tests/phpunit/tests/ajax/wpAjaxUpdateTheme.php:157
}}}

Replicating the `wp_installing()` status changes in this test too resolves the error.

Follow-up to [38168], [38710], [54722], [54723].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54725 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Oct 30, 2022
1 parent 385dbbe commit 3196ab6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/phpunit/tests/ajax/wpAjaxUpdateTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,18 @@ public function test_uppercase_theme_slug() {
$_POST['_ajax_nonce'] = wp_create_nonce( 'updates' );
$_POST['slug'] = 'camelCase';

// Prevent wp_update_themes() from running.
wp_installing( true );

// Make the request.
try {
$this->_handleAjax( 'update-theme' );
} catch ( WPAjaxDieContinueException $e ) {
unset( $e );
}

wp_installing( false );

// Get the response.
$response = json_decode( $this->_last_response, true );

Expand Down

0 comments on commit 3196ab6

Please sign in to comment.