~ubuntu-branches/debian/sid/wordpress/sid

« back to all changes in this revision

Viewing changes to wp-includes/update.php

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2014-01-24 22:20:08 UTC
  • mfrom: (1.2.31)
  • Revision ID: package-import@ubuntu.com-20140124222008-wgyk0hvmhjkubf9i
Tags: 3.8.1+dfsg-1
* New upstream release.
* Depend on either mysql or mariadb client Closes: #732914

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * @uses $wp_version Used to check against the newest WordPress version.
19
19
 *
20
20
 * @param array $extra_stats Extra statistics to report to the WordPress.org API.
 
21
 * @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
22
 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
22
23
 */
23
 
function wp_version_check( $extra_stats = array() ) {
 
24
function wp_version_check( $extra_stats = array(), $force_check = false ) {
24
25
        if ( defined('WP_INSTALLING') )
25
26
                return;
26
27
 
31
32
        $current = get_site_transient( 'update_core' );
32
33
        $translations = wp_get_installed_translations( 'core' );
33
34
 
 
35
        // Invalidate the transient when $wp_version changes
 
36
        if ( is_object( $current ) && $wp_version != $current->version_checked )
 
37
                $current = false;
 
38
 
34
39
        if ( ! is_object($current) ) {
35
40
                $current = new stdClass;
36
41
                $current->updates = array();
37
42
                $current->version_checked = $wp_version;
38
43
        }
39
44
 
 
45
        if ( ! empty( $extra_stats ) )
 
46
                $force_check = true;
 
47
 
40
48
        // Wait 60 seconds between multiple version check requests
41
49
        $timeout = 60;
42
50
        $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
43
 
        if ( $time_not_changed && empty( $extra_stats ) )
 
51
        if ( ! $force_check && $time_not_changed )
44
52
                return false;
45
53
 
46
54
        $locale = get_locale();
90
98
                'translations' => json_encode( $translations ),
91
99
        );
92
100
 
93
 
        if ( $extra_stats )
 
101
        if ( is_array( $extra_stats ) )
94
102
                $post_body = array_merge( $post_body, $extra_stats );
95
103
 
96
104
        $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
452
460
        return $updates;
453
461
}
454
462
 
455
 
/*
 
463
/**
456
464
 * Collect counts and UI strings for available updates
457
465
 *
458
466
 * @since 3.3.0
584
592
                        $next += 12 * HOUR_IN_SECONDS;
585
593
                }
586
594
                $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
 
595
                // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
 
596
                $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
587
597
                wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
588
598
        }
589
599
}