$latest = get_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, false );
$latest_data = unserialize( $latest );
+ // trigger_error( print_r( $latest_data, true ), E_USER_NOTICE );
// check latest for time if too old then fetch latest and update time.
$stale_time = strtotime( '-' . GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_TIMEOUT );
+ // trigger_error( '$stale_time: ' . $stale_time . ' $catched time: ' . $latest_data['cached'], E_USER_NOTICE );
// If you have a cache then check to see if that cache is older than GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_TIMEOUT.
// If it is then set fetch_latest to true.
if ( $latest ) {
- if ( $latest_data['cached'] <= $stale_time ) {
+ if ( !empty( $latest_data['cached'] ) && $latest_data['cached'] <= $stale_time ) {
$fetch_latest = true;
+ // trigger_error( '$latest found but expired', E_USER_NOTICE );
+ } else if ( empty( $latest_data['cached'] ) ) {
+ $fetch_latest = true;
+ // trigger_error( '$latest found but no cached time', E_USER_NOTICE );
}
} else {
$fetch_latest = true;
+ // trigger_error( 'No $latest found', E_USER_NOTICE );
}
+ // trigger_error( '$fetch_latest: ' . $fetch_latest, E_USER_NOTICE );
// If fetch_latest then grab the newest from Relay.
if ( $fetch_latest ) {
$message_data = wp_remote_retrieve_body( $response );
$status = wp_remote_retrieve_response_code( $response);
// Initialize variables
- $title = $dashboard_message = $current_time = '';
+ $title = $dashboard_message = '';
$id = $updated = false;
// If we get a good response.
} else {
$latest_version = false;
}
+ // trigger_error( '$latest_version: ' . $latest_version, E_USER_NOTICE );
+ // trigger_error( '$latest_data[version]: ' . $latest_data['version'], E_USER_NOTICE );
// Need to check the latest version with what we have cached.
// If our version is the same then we're ok. Don't delete the dismiss option.
- if ( isset( $latest_data ) && isset( $latest_data['version'] ) && $latest_version == $latest_data['version'] ) {
+ if ( !empty( $latest_data ) && !empty( $latest_data['version'] ) && $latest_version == $latest_data['version'] ) {
// use the cached data
} else {
// If there's a new update then delete the dismiss option.
delete_option( GLM_SERVERSTATS_PLUGIN_RELAY_DISMISS );
+ // trigger_error( "Delete option relay dismiss: " . GLM_SERVERSTATS_PLUGIN_RELAY_DISMISS , E_USER_NOTICE );
}
$latest_data = array(