From 6782686192d5098da904d6fbd88f831f75559b51 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 19 Jun 2014 23:21:16 +0000 Subject: [PATCH] Increase the timeout for plugin and theme update checks based on how many are being checked. Props dd32. Fixes #25788 Built from https://develop.svn.wordpress.org/trunk@28782 git-svn-id: http://core.svn.wordpress.org/trunk@28595 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/update.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/wp-includes/update.php b/wp-includes/update.php index 797358dd04..e9b1528afa 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -264,8 +264,17 @@ function wp_update_plugins( $extra_stats = array() ) { */ $locales = apply_filters( 'plugins_update_check_locales', $locales ); + if ( defined( 'DOING_CRON' ) && DOING_CRON ) { + $timeout = 30; + } elseif ( count( $plugins ) > 10 ) { + // One extra second for every 10 plugins + $timeout = 3 + intval( count( $plugins ) / 10 ); + } else { + $timeout = 3; + } + $options = array( - 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), + 'timeout' => $timeout, 'body' => array( 'plugins' => json_encode( $to_send ), 'translations' => json_encode( $translations ), @@ -412,8 +421,17 @@ function wp_update_themes( $extra_stats = array() ) { */ $locales = apply_filters( 'themes_update_check_locales', $locales ); + if ( defined( 'DOING_CRON' ) && DOING_CRON ) { + $timeout = 30; + } elseif ( count( $themes ) > 10 ) { + // One extra second for every 10 themes + $timeout = 3 + intval( count( $themes ) / 10 ); + } else { + $timeout = 3; + } + $options = array( - 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), + 'timeout' => $timeout, 'body' => array( 'themes' => json_encode( $request ), 'translations' => json_encode( $translations ),