function votingapi_update_7202 in Voting API 7.2
Queue orphaned votes for deletion (nodes and comments).
File
- ./
votingapi.install, line 180 - Installation file for VotingAPI module.
Code
function votingapi_update_7202() {
$tables[] = 'votingapi_vote';
$tables[] = 'votingapi_cache';
$types[] = array(
'node',
'node',
'nid',
);
$types[] = array(
'comment',
'comment',
'cid',
);
$queue = DrupalQueue::get('VotingAPIOrphaned', TRUE);
foreach ($types as $w) {
list($type, $type_table, $type_key) = $w;
if (!db_table_exists($type_table)) {
continue;
}
foreach ($tables as $table) {
$sql = "SELECT v.entity_type, v.entity_id FROM {{$table}} v\n LEFT OUTER JOIN {{$type_table}} e ON v.entity_id=e.{$type_key}\n WHERE v.entity_type='{$type}' AND e.{$type_key} IS NULL\n GROUP BY v.entity_type, v.entity_id";
$result = db_query($sql);
foreach ($result as $row) {
$queue
->createItem((array) $row);
}
}
}
}