function _advancedqueue_release_stale_items in Advanced Queue 7
Helper function to release stale items.
Requeues long expired entries that are in processing state. Items can be stuck in the ADVANCEDQUEUE_STATUS_PROCESSING state if the PHP process crashes or is killed while processing an item.
1 call to _advancedqueue_release_stale_items()
- _advancedqueue_cleanup_table in ./
advancedqueue.module - Helper function to clean the advancedqueue table.
File
- ./
advancedqueue.module, line 360 - Helper module for advanced queuing.
Code
function _advancedqueue_release_stale_items($timeout) {
$before = REQUEST_TIME - $timeout;
$items = db_select('advancedqueue', 'a')
->fields('a', array(
'item_id',
'name',
))
->condition('status', ADVANCEDQUEUE_STATUS_PROCESSING)
->condition('expire', $before, '<=')
->orderBy('name')
->execute();
$queues = array();
// Releasing stale items to put them back in queued status.
foreach ($items as $item) {
// DrupalQueue::get() statically caches queues objects,
// we wouldn't improve performance by grouping items by queue.
$queue = DrupalQueue::get($item->name);
$queue
->releaseItem($item);
}
}