Ticket #32444: 32444.6.diff
File 32444.6.diff, 8.1 KB (added by , 10 years ago) |
---|
-
src/wp-includes/update.php
14 14 * isn't installing. 15 15 * 16 16 * @since 2.3.0 17 * @uses $wp_version Used to check against the newest WordPress version. 17 * @global string $wp_version Used to check against the newest WordPress version. 18 * @global wpdb $wpdb 19 * @global string $wp_local_package 18 20 * 19 21 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 20 * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. 21 * @return null|false Returns null if update is unsupported. Returns false if check is too soon. 22 * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. 22 23 */ 23 24 function wp_version_check( $extra_stats = array(), $force_check = false ) { 24 if ( defined( 'WP_INSTALLING') )25 if ( defined( 'WP_INSTALLING' ) ) { 25 26 return; 27 } 26 28 27 global $wpdb, $wp_local_package; 28 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 29 global $wp_version, $wpdb, $wp_local_package; 30 // include an unmodified $wp_version 31 include( ABSPATH . WPINC . '/version.php' ); 29 32 $php_version = phpversion(); 30 33 31 34 $current = get_site_transient( 'update_core' ); … … 47 50 // Wait 60 seconds between multiple version check requests 48 51 $timeout = 60; 49 52 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); 50 if ( ! $force_check && $time_not_changed ) 51 return false; 53 if ( ! $force_check && $time_not_changed ) { 54 return; 55 } 52 56 53 $locale = get_locale();54 57 /** 55 58 * Filter the locale requested for WordPress core translations. 56 59 * … … 58 61 * 59 62 * @param string $locale Current locale. 60 63 */ 61 $locale = apply_filters( 'core_version_check_locale', $locale);64 $locale = apply_filters( 'core_version_check_locale', get_locale() ); 62 65 63 66 // Update last_checked for current to prevent multiple blocking requests if request hangs 64 67 $current->last_checked = time(); … … 120 123 $response = wp_remote_post( $http_url, $options ); 121 124 } 122 125 123 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) 124 return false; 126 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { 127 return; 128 } 125 129 126 130 $body = trim( wp_remote_retrieve_body( $response ) ); 127 131 $body = json_decode( $body, true ); 128 132 129 if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) 130 return false; 133 if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) { 134 return; 135 } 131 136 132 137 $offers = $body['offers']; 133 138 … … 177 182 * api.wordpress.org. Will only check if WordPress isn't installing. 178 183 * 179 184 * @since 2.3.0 180 * @ uses$wp_version Used to notify the WordPress version.185 * @global string $wp_version Used to notify the WordPress version. 181 186 * 182 187 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 183 * @return false|null Returns null if update is unsupported. Returns false if check is too soon.184 188 */ 185 189 function wp_update_plugins( $extra_stats = array() ) { 186 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 190 if ( defined( 'WP_INSTALLING' ) ) { 191 return; 192 } 187 193 188 if ( defined('WP_INSTALLING') ) 189 return false; 194 global $wp_version; 195 // include an unmodified $wp_version 196 include( ABSPATH . WPINC . '/version.php' ); 190 197 191 198 // If running blog-side, bail unless we've not checked in the last 12 hours 192 199 if ( !function_exists( 'get_plugins' ) ) … … 244 251 } 245 252 246 253 // Bail if we've checked recently and if nothing has changed 247 if ( ! $plugin_changed ) 248 return false; 254 if ( ! $plugin_changed ) { 255 return; 256 } 249 257 } 250 258 251 259 // Update last_checked for current to prevent multiple blocking requests if request hangs … … 254 262 255 263 $to_send = compact( 'plugins', 'active' ); 256 264 257 $locales = array( get_locale() );258 265 /** 259 266 * Filter the locales requested for plugin translations. 260 267 * … … 262 269 * 263 270 * @param array $locales Plugin locale. Default is current locale of the site. 264 271 */ 265 $locales = apply_filters( 'plugins_update_check_locales', $locales);272 $locales = apply_filters( 'plugins_update_check_locales', array( get_locale() ) ); 266 273 267 274 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 268 275 $timeout = 30; … … 296 303 $raw_response = wp_remote_post( $http_url, $options ); 297 304 } 298 305 299 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) 300 return false; 306 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 307 return; 308 } 301 309 302 310 $response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); 303 311 foreach ( $response['plugins'] as &$plugin ) { … … 334 342 * @uses $wp_version Used to notify the WordPress version. 335 343 * 336 344 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 337 * @return false|null Returns null if update is unsupported. Returns false if check is too soon.338 345 */ 339 346 function wp_update_themes( $extra_stats = array() ) { 340 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 347 if ( defined( 'WP_INSTALLING' ) ) { 348 return; 349 } 350 global $wp_version; 351 // include an unmodified $wp_version 352 include( ABSPATH . WPINC . '/version.php' ); 341 353 342 if ( defined( 'WP_INSTALLING' ) )343 return false;344 345 354 $installed_themes = wp_get_themes(); 346 355 $translations = wp_get_installed_translations( 'themes' ); 347 356 … … 407 416 } 408 417 409 418 // Bail if we've checked recently and if nothing has changed 410 if ( ! $theme_changed ) 411 return false; 419 if ( ! $theme_changed ) { 420 return; 421 } 412 422 } 413 423 414 424 // Update last_checked for current to prevent multiple blocking requests if request hangs … … 417 427 418 428 $request['themes'] = $themes; 419 429 420 $locales = array( get_locale() );421 430 /** 422 431 * Filter the locales requested for theme translations. 423 432 * … … 425 434 * 426 435 * @param array $locales Theme locale. Default is current locale of the site. 427 436 */ 428 $locales = apply_filters( 'themes_update_check_locales', $locales);437 $locales = apply_filters( 'themes_update_check_locales', array( get_locale() ) ); 429 438 430 439 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 431 440 $timeout = 30; … … 458 467 $raw_response = wp_remote_post( $http_url, $options ); 459 468 } 460 469 461 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) 462 return false; 470 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 471 return; 472 } 463 473 464 474 $new_update = new stdClass; 465 475 $new_update->last_checked = time(); … … 492 502 * Retrieves a list of all language updates available. 493 503 * 494 504 * @since 3.7.0 505 * 506 * @return array 495 507 */ 496 508 function wp_get_translation_updates() { 497 509 $updates = array(); 498 510 $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' ); 499 511 foreach ( $transients as $transient => $type ) { 500 501 512 $transient = get_site_transient( $transient ); 502 513 if ( empty( $transient->translations ) ) 503 514 continue; … … 506 517 $updates[] = (object) $translation; 507 518 } 508 519 } 509 510 520 return $updates; 511 521 } 512 522 … … 571 581 return apply_filters( 'wp_get_update_data', $update_data, $titles ); 572 582 } 573 583 584 /** 585 * @global string $wp_version 586 */ 574 587 function _maybe_update_core() { 588 global $wp_version; 575 589 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 576 590 577 591 $current = get_site_transient( 'update_core' ); 578 592 579 if ( isset( $current->last_checked ) &&593 if ( isset( $current->last_checked, $current->version_checked ) && 580 594 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) && 581 isset( $current->version_checked ) && 582 $current->version_checked == $wp_version ) 595 $current->version_checked == $wp_version ) { 583 596 return; 584 597 } 585 598 wp_version_check(); 586 599 } 587 600 /** … … 614 627 $current = get_site_transient( 'update_themes' ); 615 628 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) 616 629 return; 617 618 630 wp_update_themes(); 619 631 } 620 632