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
58 changes: 58 additions & 0 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1131,3 +1131,61 @@ Feature: Manage WordPress plugins
"""
Warning: example: This update requires PHP version 100
"""

@require-wp-4.0
Scenario: The unavailable reason of one plugin does not leak into other plugins
Given a WP install
And a wp-content/plugins/aaa-example/aaa-example.php file:
"""
<?php
/**
* Plugin Name: AAA Example Plugin
* Version: 1.0.0
* Requires at least: 3.7
* Tested up to: 6.7
"""
And a wp-content/plugins/zzz-example/zzz-example.php file:
"""
<?php
/**
* Plugin Name: ZZZ 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": {
"aaa-example/aaa-example.php": {
"id": "w.org/plugins/aaa-example",
"slug": "aaa-example",
"plugin": "aaa-example/aaa-example.php",
"new_version": "2.0.0",
"requires": "3.7",
"tested": "6.6",
"requires_php": "100",
"requires_plugins": [],
"compatibility": []
}
},
"translations": [],
"no_update": []
}
"""

When I run `wp plugin list --fields=name,update,update_unavailable_reason --format=csv`
Then STDOUT should contain:
"""
aaa-example,unavailable,"This update requires PHP version 100
"""
And STDOUT should contain:
"""
zzz-example,none,
"""
And STDOUT should not contain:
"""
zzz-example,none,"
"""
58 changes: 58 additions & 0 deletions features/theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,64 @@ Feature: Manage WordPress themes
Warning: example: This update requires PHP version 100
"""

Scenario: The unavailable reason of one theme does not leak into other themes
Given a WP install
And a wp-content/themes/aaa-example/style.css file:
"""
/*
Theme Name: aaa-example
Version: 1.0.0
*/
"""
And a wp-content/themes/aaa-example/index.php file:
"""
<?php
// Silence is golden.
"""
And a wp-content/themes/zzz-example/style.css file:
"""
/*
Theme Name: zzz-example
Version: 1.0.0
*/
"""
And a wp-content/themes/zzz-example/index.php file:
"""
<?php
// Silence is golden.
"""
And that HTTP requests to https://api.wordpress.org/themes/update-check/1.1/ will respond with:
"""
HTTP/1.1 200 OK

{
"themes": {
"aaa-example": {
"theme": "aaa-example",
"new_version": "2.0.0",
"requires": "3.7",
"requires_php": "100"
}
},
"translations": [],
"no_update": []
}
"""

When I run `wp theme list --fields=name,update,update_unavailable_reason --format=csv`
Then STDOUT should contain:
"""
aaa-example,unavailable,"This update requires PHP version 100
"""
And STDOUT should contain:
"""
zzz-example,none,
"""
And STDOUT should not contain:
"""
zzz-example,none,"
"""

@require-wp-5.9
Scenario: Check theme type field for block themes
Given a WP install
Expand Down
5 changes: 4 additions & 1 deletion src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,9 @@ protected function get_item_list() {
// filter out plugins based on PHP requirements -- so we must do that here
$compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' );

// Reset for each plugin so a previous plugin's reason does not leak into this row.
$update_unavailable_reason = '';

if ( ! $compatible_php ) {
$update = 'unavailable';

Expand Down Expand Up @@ -1030,7 +1033,7 @@ protected function get_item_list() {
'wporg_status' => $wporg_info['status'],
'wporg_last_updated' => $wporg_info['last_updated'],
'recently_active' => in_array( $file, array_keys( $recently_active ), true ),
'update_unavailable_reason' => isset( $update_unavailable_reason ) ? $update_unavailable_reason : '',
'update_unavailable_reason' => $update_unavailable_reason,
];

if ( $this->check_headers['tested_up_to'] ) {
Expand Down
5 changes: 4 additions & 1 deletion src/WP_CLI/ParseThemeNameInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ private function get_all_themes() {
$compatible_php = empty( $requires_php ) || version_compare( PHP_VERSION, $requires_php, '>=' );
$compatible_wp = empty( $requires ) || version_compare( $wp_version, $requires, '>=' );

// Reset for each theme so a previous theme's reason does not leak into this row.
$update_unavailable_reason = '';

if ( ! $compatible_php ) {
$update = 'unavailable';

Expand Down Expand Up @@ -155,7 +158,7 @@ private function get_all_themes() {
'auto_update_indicated' => $auto_update_indicated,
'requires' => $requires,
'requires_php' => $requires_php,
'update_unavailable_reason' => isset( $update_unavailable_reason ) ? $update_unavailable_reason : '',
'update_unavailable_reason' => $update_unavailable_reason,
'type' => $theme_type,
];

Expand Down