Make WordPress Core

Opened 12 years ago

Closed 4 years ago

Last modified 4 years ago

#20615 closed defect (bug) (fixed)

Unknown error when running plugins_api() with invalid slug

Reported by: scribu's profile scribu Owned by:
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

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.

Change History (9)

#1 @nacin
12 years ago

N; is a serialized null.

#2 @samuelsidler
11 years ago

  • Milestone WordPress.org deleted
  • Status changed from new to closed

Migrated to #meta111.

#3 @SergeyBiryukov
11 years ago

  • Resolution set to duplicate

#4 follow-up: @dd32
11 years ago

FYI, This isn't api.WordPress.org specific at all, and requires primarily WordPress changes in the plugins_api() function. But it would be nice for the API to return more than just "NULL".

#5 in reply to: ↑ 4 @SergeyBiryukov
11 years ago

Replying to dd32:

But it would be nice for the API to return more than just "NULL".

Yes, looks like currently there's no reliable way to detect if the request failed due to an invalid slug and not some general error. We would just have to assume that null means an invalid slug.

Last edited 11 years ago by SergeyBiryukov (previous) (diff)

#6 @dd32
7 years ago

  • Component changed from WordPress.org site to Upgrade/Install
  • Milestone set to Awaiting Review
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Reopening this as #meta111 is blocked by core (possibly forever? until we migrate core to use /info/1.1/)

This ticket was mentioned in Slack in #core-auto-updates by pbiron. View the logs.


4 years ago

#8 @pbiron
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

As of [42631], core has been using API version 1.2, which correctly handles this case. Thus, plugins_api() returns the correct WP_Error instance.

Closing as fixed.

#9 @desrosj
4 years ago

  • Milestone changed from Awaiting Review to 5.1
Note: See TracTickets for help on using tickets.