Make WordPress Core

Opened 6 weeks ago

Last modified 4 weeks ago

#63078 new defect (bug)

plugins_api() Default Argument Issue: 'downloaded' Not Set to True

Reported by: wpessential's profile wpessential Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 6.7.2
Component: Plugins Keywords: needs-dev-note has-patch 2nd-opinion
Focuses: Cc:

Description

The plugins_api() function has default arguments; among them, the downloaded field is supposed to be true by default. However, it is not.

plugins_api('plugin_information', ['active_installs' => true]);

Change History (9)

This ticket was mentioned in PR #8483 on WordPress/wordpress-develop by @snehapatil02.


6 weeks ago
#1

  • Keywords has-patch added

Set downloaded to true by default in plugins_api()

Trac ticket: https://core.trac.wordpress.org/ticket/63078

#2 follow-up: @debarghyabanerjee
6 weeks ago

Hi @wpessential,

Thanks for raising the ticket. I've reviewed the core code and found that the downloaded propery is part of the fields property in the argument, $args. According to the documentation, the downloaded parameter is set to true by default, which means that the response from the API api.wordpress.org/plugins/) will include the downloaded field by default.

To clarify, the plugin_api() function makes a remote request to api.wordpress.org/plugins/ to fetch plugin details. As part of the response, the downloaded field will be included unless you specify otherwise. If you want to exclude this field from the response, you can pass 'fields' => array( 'downloaded' => false ) in the arguments.

For further reference, you can check the Codex documentation here:
https://codex.wordpress.org/WordPress.org_API#:~:text=update%2Dcheck/1.1/-,Plugins,-https%3A//api.wordpress

Let me know if you have any questions!

Last edited 6 weeks ago by debarghyabanerjee (previous) (diff)

#3 in reply to: ↑ 2 ; follow-up: @wpessential
6 weeks ago

Replying to debarghyabanerjee:

Hi,
Thank you for your reply. You are right. But the default value of downloaded is not working, as the documentation mentions (true).

#4 in reply to: ↑ 3 ; follow-up: @debarghyabanerjee
6 weeks ago

Replying to wpessential:
Hummmm, yes, you're right. After reviewing the source code for api.wordpress.org/plugins/info/, I found the reason behind the issue.

The downloaded field was set to true by default up until API version 1.1 (i.e., /plugins/info/1.1/). However, with the introduction of version 1.2, the list of default fields changed, and now the following fields are set to true by default for plugin_information:

'banners'
'reviews'
'active_installs'
'contributors'
'preview_link'
'upgrade_notice'
'business_model'
'repository_url'
'support_url'
'commercial_support_url'

It's worth noting that version 1.2 was introduced 7 years ago, while the documentation was last updated 9 years ago, meaning it provides inaccurate information.

In my opinion, the documentation should be updated to reflect the current default fields. Instead of manually setting 'downloaded' => true.

You can reference the change in the source code here https://github.com/WordPress/wordpress.org/blob/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php#L73

#5 in reply to: ↑ 4 ; follow-up: @wpessential
6 weeks ago

Replying to debarghyabanerjee:

I think we need to update the downloaded value from false to true according to the documentation.
What do you think?

#6 in reply to: ↑ 5 @debarghyabanerjee
6 weeks ago

Replying to wpessential:

IMHO, I am against manually setting the downloaded field to true. My reason is that the documentation references the default fields from the api.wordpress.org/plugins/info, so we should update the documentation accordingly instead of manually setting the downloaded field to true.

#7 @debarghyabanerjee
6 weeks ago

  • Keywords 2nd-opinion added

#8 @debarghyabanerjee
6 weeks ago

Hi @dd32, Hope you are doing well. I noticed that you were part of the plugins/info API version upgrade. Can you please share your thoughts on the discussion above?

Last edited 6 weeks ago by debarghyabanerjee (previous) (diff)

#9 @dd32
4 weeks ago

Let's just change the API to add downloaded: true by default.

Note: See TracTickets for help on using tickets.