function flag_session_api_cleanup in Flag 7.2
Same name and namespace in other branches
- 6.2 flag.module \flag_session_api_cleanup()
- 7.3 flag.module \flag_session_api_cleanup()
Implements hook_session_api_cleanup().
Clear out anonymous user flaggings during Session API cleanup.
File
- ./
flag.module, line 891 - The Flag module.
Code
function flag_session_api_cleanup($arg = 'run') {
// Session API 1.1 version:
if ($arg == 'run') {
$query = db_select('flag_content', 'fc');
$query
->leftJoin('session_api', 's', 'fc.sid = s.sid');
$result = $query
->fields('fc', array(
'sid',
))
->condition('fc.sid', 0, '<>')
->isNull('s.sid')
->execute();
foreach ($result as $row) {
db_delete('flag_content')
->condition('sid', $row->sid)
->execute();
}
}
elseif (is_array($arg)) {
$outdated_sids = $arg;
db_delete('flag_content')
->condition('sid', $outdated_sids, 'IN')
->execute();
}
}