features/plugin-list-wporg-status.feature:32-41 mocks the plugin-info API response for no-longer-in-directory with unquoted keys:
{
error: "closed",
name: "No Longer in Directory",
...
}
That is not JSON. WpOrgApi::get_plugin_info() runs json_decode() and throws on the decode error (wp-cli/php/WP_CLI/WpOrgApi.php:311-314), so get_wporg_data() lands in the catch at src/Plugin_Command.php:1126 and marks the plugin closed only because the trac request is not a 404 (:1140-1141). The scenario therefore tests the "API request failed" path, not a real closure response.
The real API answers a closed plugin with HTTP 200 and a body like {"error":"closed","name":"...","closed":true,"closed_date":"2018-10-02","reason":"guideline-violation"}. get_wporg_data() treats any decoded body as active (:1129), so with a valid fixture the scenario would report active for a closed plugin.
Two things to do:
- Quote the keys in the fixture so it is valid JSON.
- Make
get_wporg_data() recognise error: "closed" (or closed: true) in a decoded response and return closed without the trac round trip. Keep the trac fallback covered by a separate scenario where the API is unreachable.
Found while reviewing #547; predates it.
features/plugin-list-wporg-status.feature:32-41mocks the plugin-info API response forno-longer-in-directorywith unquoted keys:That is not JSON.
WpOrgApi::get_plugin_info()runsjson_decode()and throws on the decode error (wp-cli/php/WP_CLI/WpOrgApi.php:311-314), soget_wporg_data()lands in thecatchatsrc/Plugin_Command.php:1126and marks the pluginclosedonly because the trac request is not a 404 (:1140-1141). The scenario therefore tests the "API request failed" path, not a real closure response.The real API answers a closed plugin with HTTP 200 and a body like
{"error":"closed","name":"...","closed":true,"closed_date":"2018-10-02","reason":"guideline-violation"}.get_wporg_data()treats any decoded body asactive(:1129), so with a valid fixture the scenario would reportactivefor a closed plugin.Two things to do:
get_wporg_data()recogniseerror: "closed"(orclosed: true) in a decoded response and returnclosedwithout the trac round trip. Keep the trac fallback covered by a separate scenario where the API is unreachable.Found while reviewing #547; predates it.