bobbingwide / oik-bob-bing-wide

More lazy smart shortcodes
https://www.oik-plugins.com/oik-plugins/oik-bob-bing-wide-more-lazy-smart-shortcodes/
GNU General Public License v2.0
2 stars 0 forks source link

bw_get_plugin_info2() getting unexpected result from api.wordpress.org #21

Open bobbingwide opened 7 years ago

bobbingwide commented 7 years ago

bw_get_plugin_info2() is now receiving a different result from its request being performed by the following code

$request_url = "http://api.wordpress.org/plugins/info/1.0/$plugin_slug.info";
$response_xml = bw_remote_get2( $request_url ); //, null );

Expected output

For some plugins hosted on WordPress the [bw_plug] shortcode would display the latest available information for the plugin.

Actual output

No info available

For some plugins the results appear to be unchanged. I'll need to confirm this! I don't think it's the local caching of the results in transients.

Explanation

In a brief discussion on WordPress Slack Meta channel I was advised that I was using an endpoint that's not officially supported. https://wordpress.slack.com/archives/C02QB8GMM/p1495034365502545

Subsequent messages indicated that there are a variety of acceptable formats giving slightly different results.

It turns out that in order to continue to receive the response as serialized data I should either remove the .info or change it to .php For JSON format data I could use the .json suffix.

It's odd that the code had worked fine since April 2015 but is playing up now. I suspect it's something to do with the new plugin directory.

Not sure if I've found the right source files... https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php

https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php

bobbingwide commented 7 years ago

Follow on problem. Having changed the code to remove the .info from the URL the result is once again being returned as serialized data. But I'm getting Notices about the short_description property not being defined.

It turns out that short_description isn't a default field so it needs to be requested using ?fields[short_description]=true.

This didn't work without the .php suffix

http://api.wordpress.org/plugins/info/1.0/jetpack?fields[short_description]=true

But does work as http://api.wordpress.org/plugins/info/1.0/jetpack.php?fields[short_description]=true

bobbingwide commented 7 years ago

It seems that test_bw_plug_banner_image_url() was not changed but should have been.

There is now another problem with this test when run in the local environments qw/wordpress or qw/oikcom.

... the short_description for oik is not that from wordpress.org.

It is correct when run from qw/src. Workaround: deactivate oik-plugins