From 7b33ad2a997e3acf06d1fb3196299cb5155a289d Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Sat, 26 Sep 2015 15:50:25 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@34598 git-svn-id: http://core.svn.wordpress.org/trunk@34562 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/update-core.php | 21 +++++++++++++++++++-- wp-admin/update.php | 25 +++++++++++++++++++++---- wp-includes/version.php | 2 +- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index 3e3e24c60f..d52b415e6e 100644 --- a/wp-admin/update-core.php +++ b/wp-admin/update-core.php @@ -252,8 +252,25 @@ function list_plugin_updates() { $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; } diff --git a/wp-admin/update.php b/wp-admin/update.php index 4cfdeca6c6..fba26f885a 100644 --- a/wp-admin/update.php +++ b/wp-admin/update.php @@ -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'; diff --git a/wp-includes/version.php b/wp-includes/version.php index fe0705e913..3a05523705 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34597'; +$wp_version = '4.4-alpha-34598'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.