Plugins: Don't request all fields via plugins_api( 'plugin_information' ) for plugin installs and update checks.

The Plugins API returns a lot of data by default (see [34596]) but when installing or checking for updates we don't need all of it. To save bandwidth, memory and time request only required fields.

Fixes #34030.

git-svn-id: https://develop.svn.wordpress.org/trunk@34598 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-09-26 15:49:06 +00:00
parent 60660b0055
commit 5da80b3d64
2 changed files with 40 additions and 6 deletions

View File

@ -252,8 +252,25 @@ function list_plugin_updates() {
<tbody class="plugins">
<?php
foreach ( (array) $plugins as $plugin_file => $plugin_data) {
$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
$info = plugins_api( 'plugin_information', array(
'slug' => $plugin_data->update->slug,
'fields' => array(
'short_description' => false,
'sections' => false,
'requires' => false,
'rating' => false,
'ratings' => false,
'downloaded' => false,
'downloadlink' => false,
'last_updated' => false,
'added' => false,
'tags' => false,
'homepage' => false,
'donate_link' => false,
),
) );
if ( is_wp_error( $info ) ) {
$info = false;
}

View File

@ -97,11 +97,28 @@ if ( isset($_GET['action']) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
check_admin_referer('install-plugin_' . $plugin);
$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
check_admin_referer( 'install-plugin_' . $plugin );
$api = plugins_api( 'plugin_information', array(
'slug' => $plugin,
'fields' => array(
'short_description' => false,
'sections' => false,
'requires' => false,
'rating' => false,
'ratings' => false,
'downloaded' => false,
'last_updated' => false,
'added' => false,
'tags' => false,
'compatibility' => false,
'homepage' => false,
'donate_link' => false,
),
) );
if ( is_wp_error($api) )
wp_die($api);
if ( is_wp_error( $api ) ) {
wp_die( $api );
}
$title = __('Plugin Install');
$parent_file = 'plugins.php';