Opened 5 years ago
Closed 5 years ago
#47835 closed defect (bug) (fixed)
PHP requirement always set to null for plugins
Reported by: | diddledani | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.2.3 | Priority: | normal |
Severity: | minor | Version: | 5.2 |
Component: | Site Health | Keywords: | has-patch fixed-major |
Focuses: | Cc: |
Description
The file class-wp-plugins-list-table.php line 764 (https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-plugins-list-table.php#L764) references a variable called $plugin
. This variable is not defined anywhere in the function so the test will always return false, meaning that $requires_php
will always be set to null
:
$requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
This line was introduced in version 5.2.0
Attachments (4)
Change History (15)
#5
@
5 years ago
- Milestone changed from 5.2.3 to 5.3
This turned out to be not as straightforward as it seems :)
Background:
- [44937] introduced PHP compatibility check in
WP_Plugins_List_Table::single_row()
- [45185] updated the check to use the new
is_php_version_compatible()
function.
Initially, I thought the check should be updated to use validate_plugin_requirements()
to account for the data both from the plugin's main PHP file and readme.txt
:
$compatible_php = ! is_wp_error( validate_plugin_requirements( $plugin_file ) );
However, upon a closer look, the purpose of the PHP compatibility check in this particular place is to disable the checkbox that could be used for bulk updating plugins, as some of the plugin updates might be incompatible.
The problem with this is that $plugin_data
refers to the currently installed version of the plugin (which should already by compatible per the changes in #43986 and #43992), not the updated version that might have different requirements.
The information about the update is only available in wp_plugin_update_row()
, which has its own PHP compatibility check per [44937].
So, unless I'm missing something, the current PHP compatibility check in WP_Plugins_List_Table::single_row()
doesn't work as expected even with the proposed variable correction and should be removed. See 47835.2.diff.
Disabling the checkbox for incompatible updates makes sense, but I don't see a clean way to do that at the moment.
#6
@
5 years ago
The problem with this is that
$plugin_data
refers to the currently installed version of the plugin
Nevermind, I missed that $plugin_data
is merged with the plugin API response earlier.
$plugin_data['RequiresPHP']
does indeed refer to the header from the currently installed plugin version, however $plugin_data['requires_php']
refers to the available update.
47835.diff is good to go.
#7
@
5 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 45750:
#8
@
5 years ago
- Keywords fixed-major added
- Milestone changed from 5.3 to 5.2.3
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for 5.2.3 consideration.
I think you’re correct. It should be
$plugin_data['requires_php']
.I’ll step through the the code tomorrow and make certain.
Good pick up. Thanks.