#111 closed defect (bug) (fixed)
Improve error when running plugins_api() with invalid slug
Reported by: | scribu | Owned by: | dd32 |
---|---|---|---|
Milestone: | Priority: | high | |
Component: | API | Keywords: | |
Cc: |
Description
Migrating from #wp20615:
Input:
$api = plugins_api( 'plugin_information', array( 'slug' => 'doesnt-exist' ) ); var_dump( $api );Expected result:
WP_Error Object ( [errors] => Array ( [invalid_slug] => Array ( [0] => Invalid plugin slug. ) ) [error_data] => Array ( [invalid_slug] => 404; ) )Actual result:
WP_Error Object ( [errors] => Array ( [plugins_api_failed] => Array ( [0] => An unknown error occurred during the API request. ) ) [error_data] => Array ( [plugins_api_failed] => N; ) )PS: I have no idea what that 'N' is supposed to represent.
As nacin says, N; is a serialized null. But we could improve the error message.
Change History (21)
#2
@
7 years ago
@obenland This is a core thing, not really an API thing. The API can't be changed as core (and perhaps other clients) expect null
to mean error
.
For reference, here's what the current endpoints return:
https://api.wordpress.org/plugins/info/1.1/?action=plugin_information&request[slug]=404-does-not-exist
We can change the API to return something else instead of N;
/null
however doing so will cause WordPress itself to break. I've re-opened #wp20615 for that reason.
However, Core is not currently using the 1.1
API (It's still using the 1.0
api) so what we can do is change the 1.1 error responses (I don't really care about non-WordPress clients in this case) so that when core is shifted to 1.1 it's error handling gets fixed at the same time.
#3
@
7 years ago
- Owner set to dd32
- Priority changed from low to high
- Status changed from new to assigned
#5
@
7 years ago
For consistency this probably should be changed in the query for themes too.
FWIW this did cause me a breaking change to a plugin :(
#6
@
7 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
As this broke client expectations, I'm going to revert this and push it out as a 1.2 api instead - with the intention that we also update WordPress 5.0 to use the 1.2 API going forward as well.
#12
@
7 years ago
Going to mark this as completed.
FYI info/1.2
for both Themes and plugins should be considered alpha until such a time that a WordPress release uses them. That'll most likely be the WordPress 5.0 release, but check #wp20615.
Some changes may be made to the response format as needed, for example, having a different default result set.
@dd32 Is this something that is easier to do now?