function weather_cron in Weather 5.6
Same name and namespace in other branches
- 6.5 weather.module \weather_cron()
- 7.3 weather.module \weather_cron()
- 7.2 weather.module \weather_cron()
Implementation of hook_cron().
If the site uses caching for anonymous users, the cached weather blocks are not updated until the page cache is flushed. We rely on cron to perform necessary updates (and flushing the cache) for anonymous users. In order to not clear the cache for user-defined weather blocks (which are not shown to anonymous users), we only check for the system weather block.
File
- ./
weather.module, line 201 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function weather_cron() {
if (variable_get('weather_use_cron', FALSE)) {
$sql = "SELECT * FROM {weather} LEFT JOIN {weather_config}\n ON {weather}.icao={weather_config}.icao\n WHERE {weather_config}.uid=%d ORDER BY next_update_on ASC";
$result = db_query($sql, WEATHER_SYSTEM_BLOCK);
$row = db_fetch_array($result);
if (isset($row['next_update_on'])) {
if ($row['next_update_on'] <= time()) {
cache_clear_all();
}
}
}
}