Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,51 @@ Feature: Manage WordPress plugins
Warning: example: This update requires WordPress version 100
"""

@require-wp-4.0
Scenario: Show plugin update as unavailable if it has a new version but no update package provided by author
Given a WP install
And a wp-content/plugins/example/example.php file:
"""
<?php
/**
* Plugin Name: Example Plugin
* Version: 1.0.0
* Requires at least: 3.7
* Tested up to: 6.7
"""
And that HTTP requests to https://api.wordpress.org/plugins/update-check/1.1/ will respond with:
"""
HTTP/1.1 200 OK

{
"plugins": [],
"translations": [],
"no_update": {
"example/example.php": {
"id": "w.org/plugins/example",
"slug": "example",
"plugin": "example/example.php",
"new_version": "2.0.0",

"requires_plugins": [],
"compatibility": []
}
}
}
"""

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version | update_version | auto_update | requires | requires_php |
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | | |

When I try `wp plugin update example`
Then STDERR should contain:
"""
Warning: example: Update file not provided. Contact author for more details
"""


@require-wp-4.0
Scenario: Show plugin update as unavailable if it doesn't meet PHP requirements
Given a WP install
Expand Down
13 changes: 10 additions & 3 deletions src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,15 +864,22 @@
$items[ $file ]['requires_php'] = isset( $plugin_update_info->requires_php ) ? $plugin_update_info->requires_php : null;
}

// If there is a plugin in no_update with a newer version than the local copy, it is because the plugins update api
// has already filtered it because the local WordPress version is too low
// If there is a plugin in no_update with a newer version than the local copy, it is either because:
// A: the plugins update API has already filtered it because the local WordPress version is too low
// B: It is possibly a paid plugin that has an update which the user does not qualify for
if ( null !== $plugin_update_info && version_compare( $details['Version'], $plugin_update_info->new_version, '<' ) ) {
$items[ $file ]['update'] = 'unavailable';
$items[ $file ]['update_version'] = $plugin_update_info->new_version;
$items[ $file ]['requires'] = isset( $plugin_update_info->requires ) ? $plugin_update_info->requires : null;
$items[ $file ]['requires_php'] = isset( $plugin_update_info->requires_php ) ? $plugin_update_info->requires_php : null;

$reason = "This update requires WordPress version $plugin_update_info->requires, but the version installed is $wp_version.";
if ( isset( $plugin_update_info->requires ) && version_compare( $wp_version, $requires, '>=' ) ) {
$reason = "This update requires WordPress version $plugin_update_info->requires, but the version installed is $wp_version.";
} elseif ( ! isset( $update_info['package'] ) ) {
$reason = 'Update file not provided. Contact author for more details';
} else {
$reason = 'Update not available';

Check warning on line 881 in src/Plugin_Command.php

View check run for this annotation

Codecov / codecov/patch

src/Plugin_Command.php#L881

Added line #L881 was not covered by tests
}

$items[ $file ]['update_unavailable_reason'] = $reason;

Expand Down