WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/16/2011 07:23:15 AM (9 years ago)
Author:
nacin
Message:

Revert update changes that snuck in with [19311]. see #19255, see #18876.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/update.php

    r19311 r19312  
    144144    $new_option = new stdClass;
    145145    $new_option->last_checked = time();
    146 
    147     // Check for updated every 12 hours, 60 minutes, or immediately, depending on the page.
    148     $filter = current_filter();
    149     if ( 'load-update-core.php' != $filter ) {
    150         $timeout = 'load-plugins.php' == $filter || 'load-update.php' == $filter ? 3600 : 43200;
    151         $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
    152 
    153         if ( $time_not_changed ) {
    154             $plugin_changed = false;
    155             foreach ( $plugins as $file => $p ) {
    156                 $new_option->checked[ $file ] = $p['Version'];
    157        
    158                 if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )
    159                     $plugin_changed = true;
     146    // Check for updated every 60 minutes if hitting update pages; else, check every 12 hours.
     147    $timeout = in_array( current_filter(), array( 'load-plugins.php', 'load-update.php', 'load-update-core.php' ) ) ? 3600 : 43200;
     148    $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
     149
     150    $plugin_changed = false;
     151    foreach ( $plugins as $file => $p ) {
     152        $new_option->checked[ $file ] = $p['Version'];
     153
     154        if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )
     155            $plugin_changed = true;
     156    }
     157
     158    if ( isset ( $current->response ) && is_array( $current->response ) ) {
     159        foreach ( $current->response as $plugin_file => $update_details ) {
     160            if ( ! isset($plugins[ $plugin_file ]) ) {
     161                $plugin_changed = true;
     162                break;
    160163            }
    161 
    162             if ( isset ( $current->response ) && is_array( $current->response ) ) {
    163                 foreach ( $current->response as $plugin_file => $update_details ) {
    164                     if ( ! isset($plugins[ $plugin_file ]) ) {
    165                         $plugin_changed = true;
    166                         break;
    167                     }
    168                 }
    169             }
    170 
    171             // Bail if we've checked recently and if nothing has changed
    172             if ( ! $plugin_changed )
    173                 return false;
    174164        }
    175165    }
     166
     167    // Bail if we've checked in the last 12 hours and if nothing has changed
     168    if ( $time_not_changed && !$plugin_changed )
     169        return false;
    176170
    177171    // Update last_checked for current to prevent multiple blocking requests if request hangs
     
    229223        $last_update = new stdClass;
    230224
     225    // Check for updated every 60 minutes if hitting update pages; else, check every 12 hours.
     226    $timeout = in_array( current_filter(), array( 'load-themes.php', 'load-update.php', 'load-update-core.php' ) ) ? 3600 : 43200;
     227    $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
     228
    231229    $themes = array();
    232230    $checked = array();
     
    249247    }
    250248
    251     // Check for updated every 12 hours, 60 minutes, or immediately, depending on the page.
    252     $filter = current_filter();
    253     if ( 'load-update-core.php' != $filter ) {
    254         $timeout = 'load-themes.php' == $filter || 'load-update.php' == $filter ? 3600 : 43200;
    255         $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
    256 
    257         if ( $time_not_changed ) {
    258             $theme_changed = false;
    259             foreach ( $checked as $slug => $v ) {
    260                 $update_request->checked[ $slug ] = $v;
    261        
    262                 if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
    263                     $theme_changed = true;
     249    $theme_changed = false;
     250    foreach ( $checked as $slug => $v ) {
     251        $update_request->checked[ $slug ] = $v;
     252
     253        if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
     254            $theme_changed = true;
     255    }
     256
     257    if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) {
     258        foreach ( $last_update->response as $slug => $update_details ) {
     259            if ( ! isset($checked[ $slug ]) ) {
     260                $theme_changed = true;
     261                break;
    264262            }
    265 
    266             if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) {
    267                 foreach ( $last_update->response as $slug => $update_details ) {
    268                     if ( ! isset($checked[ $slug ]) ) {
    269                         $theme_changed = true;
    270                         break;
    271                     }
    272                 }
    273             }
    274 
    275             // Bail if we've checked recently and if nothing has changed
    276             if ( ! $theme_changed )
    277                 return false;
    278263        }
    279264    }
     265
     266    if ( $time_not_changed && !$theme_changed )
     267        return false;
    280268
    281269    // Update last_checked for current to prevent multiple blocking requests if request hangs
Note: See TracChangeset for help on using the changeset viewer.