function boost_cron in Boost 6
Same name and namespace in other branches
- 5 boost.module \boost_cron()
- 7 boost.module \boost_cron()
Implementation of hook_cron(). Performs periodic actions.
File
- ./
boost.module, line 940 - Provides static file caching for Drupal text output. Pages, Feeds, ect...
Code
function boost_cron() {
if (!variable_get('boost_enabled', CACHE_NORMAL)) {
return;
}
global $_boost;
// Remove old domains if they are now a redirect
if (module_exists('domain_alias')) {
$domains = domain_domains();
$old_domains = array();
foreach ($domains as $key => $value) {
foreach ($value['aliases'] as $alias) {
if ($alias['redirect'] == 1) {
$old_domains[] = boost_cache_directory($alias['pattern'], FALSE);
}
}
}
if (!empty($old_domains)) {
$result = boost_db_multi_select_in('boost_cache', 'base_dir', "'%s'", $old_domains);
$files = array();
while ($row = db_fetch_array($result)) {
$files[] = array(
'filename' => $row['filename'],
'hash' => $row['hash'],
);
}
if (!empty($files)) {
boost_cache_kill($files, TRUE);
boost_remove_db($files);
}
}
}
// Remove old domains if they are "inactive"
if (module_exists('domain')) {
$domains = domain_domains();
$old_domains = array();
foreach ($domains as $key => $value) {
if ($value['valid'] == 0) {
$old_domains[] = boost_cache_directory($value['subdomain'], FALSE);
}
}
if (!empty($old_domains)) {
$result = boost_db_multi_select_in('boost_cache', 'base_dir', "'%s'", $old_domains);
$files = array();
while ($row = db_fetch_array($result)) {
$files[] = array(
'filename' => $row['filename'],
'hash' => $row['hash'],
);
}
if (!empty($files)) {
boost_cache_kill($files, TRUE);
boost_remove_db($files);
}
}
}
// Check for new views on cron
if (module_exists('views') && BOOST_VIEWS_LIST_BEHAVIOR == 0) {
$defaults = boost_views_generate_default_list();
variable_set('boost_views_list_default', $defaults);
}
$expire = TRUE;
if (BOOST_CHECK_BEFORE_CRON_EXPIRE) {
$expire = boost_has_site_changed(TRUE);
}
// Expire old content
if (!BOOST_LOOPBACK_BYPASS && variable_get('boost_expire_cron', TRUE) && $expire && boost_cache_expire_all()) {
if (BOOST_VERBOSE >= 5 && isset($_boost['verbose_option_selected']['boost_cron_expire'])) {
watchdog('boost', 'Expired stale files from static page cache.', array(), WATCHDOG_NOTICE);
}
}
// Update Stats
if (module_exists('statistics') && variable_get('boost_block_show_stats', FALSE)) {
$block = module_invoke('statistics', 'block', 'view', 0);
variable_set('boost_statistics_html', $block['content']);
}
// Crawl Site
if (BOOST_CRAWL_ON_CRON && !variable_get('site_offline', 0)) {
boost_crawler_run((int) $expire);
}
}