Skip to content

Fix --skip-update-check in admin context#508

Merged
swissspidy merged 9 commits intomainfrom
copilot/fix-skip-update-check-issue
Mar 9, 2026
Merged

Fix --skip-update-check in admin context#508
swissspidy merged 9 commits intomainfrom
copilot/fix-skip-update-check-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

In WP-CLI's auto context, plugin and theme commands run as admin. WordPress core hooks wp_update_plugins/wp_update_themes to load-plugins.php/load-themes.php, which fire inside load_admin_environment() during wp_loadedbefore command dispatch—making HTTP requests to api.wordpress.org regardless of --skip-update-check.

Changes

  • extension-command.php: When --skip-update-check is present in assoc_args at bootstrap (before WordPress loads), register an admin_init hook via WP_CLI::add_wp_hook() that removes the wp_update_plugins/wp_update_themes callbacks. admin_init fires inside the admin page simulation after those callbacks are registered but before load-plugins.php/load-themes.php dispatch, preventing the HTTP requests entirely.

  • CommandWithUpgrade::_list: Added remove_action() calls for both hooks in the --skip-update-check branch as a defensive cleanup.

  • features/plugin.feature, features/theme.feature: Hardened the --skip-update-check scenarios to assert no HTTP POST is made to api.wordpress.org:

When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check --debug=http`
Then STDERR should not contain:
  """
  HTTP POST request to https://api.wordpress.org/plugins/update-check
  """
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix --skip-update-check in new admin context</issue_title>
<issue_description>In the framework we made some changes to how --context works:

This combination caused the --skip-update-check tests to fail:

@require-wp-5.2
Scenario: Flag `--skip-update-check` skips update check when running `wp plugin list`
Given a WP install
When I run `wp plugin install wordpress-importer --version=0.2`
Then STDOUT should contain:
"""
Plugin installed successfully.
"""
When I run `wp plugin list --fields=name,status,update --status=inactive`
Then STDOUT should be a table containing rows:
| name | status | update |
| wordpress-importer | inactive | available |
When I run `wp transient delete update_plugins --network`
Then STDOUT should be:
"""
Success: Transient deleted.
"""
When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check`
Then STDOUT should be a table containing rows:
| name | status | update |
| wordpress-importer | inactive | none |

@require-wp-5.3
Scenario: Flag `--skip-update-check` skips update check when running `wp theme list`
Given a WP install
When I run `wp theme install astra --version=1.0.0`
Then STDOUT should contain:
"""
Theme installed successfully.
"""
When I run `wp theme list --fields=name,status,update`
Then STDOUT should be a table containing rows:
| name | status | update |
| astra | inactive | available |
When I run `wp transient delete update_themes --network`
Then STDOUT should be:
"""
Success: Transient deleted.
"""
When I run `wp theme list --fields=name,status,update --skip-update-check`
Then STDOUT should be a table containing rows:
| name | status | update |
| astra | inactive | none |

The reason for that is core doing add_action( 'load-plugins.php', 'wp_update_plugins' ); and add_action( 'load-themes.php', 'wp_update_themes' );. So the update checks runs all the time on that page.

The easiest solution would be to unhook these two callbacks when --skip-update-check is passed. Probably within CommandWithUpgrade.

The Behat tests could be hardened to verify no HTTP requests are made, e.g.

    When I try `wp plugin list --fields=name,status,update --status=inactive --skip-update-check --debug=http`
    Then STDERR should not contain:
      """
      HTTP POST request to https://api.wordpress.org/plugins/update-check
      """
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@github-actions github-actions bot added command:plugin-list Related to 'plugin list' command command:theme Related to 'theme' command scope:testing Related to testing labels Mar 7, 2026
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix --skip-update-check in new admin context Fix --skip-update-check in admin context Mar 7, 2026
@swissspidy swissspidy marked this pull request as ready for review March 8, 2026 21:46
@swissspidy swissspidy requested a review from a team as a code owner March 8, 2026 21:46
Copilot AI review requested due to automatic review settings March 8, 2026 21:46

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy swissspidy added this to the 2.3.0 milestone Mar 9, 2026
@swissspidy swissspidy merged commit 69cbc4b into main Mar 9, 2026
59 checks passed
@swissspidy swissspidy deleted the copilot/fix-skip-update-check-issue branch March 9, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:plugin-list Related to 'plugin list' command command:theme Related to 'theme' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix --skip-update-check in new admin context

3 participants