function content_lock_timeout_cron in Content locking (anti-concurrent editing) 6.2
Same name and namespace in other branches
- 8.2 modules/content_lock_timeout/content_lock_timeout.module \content_lock_timeout_cron()
- 8 modules/content_lock_timeout/content_lock_timeout.module \content_lock_timeout_cron()
- 6 modules/content_lock_timeout/content_lock_timeout.module \content_lock_timeout_cron()
- 7.3 modules/content_lock_timeout/content_lock_timeout.module \content_lock_timeout_cron()
- 7 modules/content_lock_timeout/content_lock_timeout.module \content_lock_timeout_cron()
- 7.2 modules/content_lock_timeout/content_lock_timeout.module \content_lock_timeout_cron()
Implementation of hook_cron().
Breaks batches of stale locks whenever the cron hooks are run. Inspired by original content_lock_cron() (leftover from the checkout module).
File
- modules/
content_lock_timeout/ content_lock_timeout.module, line 57 - Allowed time-based automatic unlocking of nodes locked for editing with content_lock.
Code
function content_lock_timeout_cron() {
$timeout_minutes = variable_get('content_lock_timeout_minutes', 30);
$last_valid_time = time() - 60 * $timeout_minutes;
// We call content_lock_release() for each lock so that the
// hook_content_lock_released may be invoked.
$result = db_query('SELECT nid FROM {content_lock} WHERE timestamp < %d', $last_valid_time);
$count = 0;
while ($nid = db_result($result)) {
content_lock_release($nid);
$count++;
}
if ($count) {
$period = format_interval($timeout_minutes * 60);
watchdog('content_lock_timeout', 'Released @count stale node locks which lasted at least @period.', array(
'@count' => $count,
'@period' => $period,
));
}
}