Skip to content

Closed-plugin fixture in plugin-list-wporg-status.feature is not valid JSON #549

Description

@schlessera

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:

  1. Quote the keys in the fixture so it is valid JSON.
  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions