Skip to content

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

@swissspidy

Description

@swissspidy

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
      """

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions