function biblio_delete_orphan_keywords in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()
- 6 biblio.keywords.inc \biblio_delete_orphan_keywords()
- 7 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()
2 calls to biblio_delete_orphan_keywords()
- BiblioKeywordUnitTest::testBiblioDeleteOrphanKeywords in tests/
keyword.test - biblio_cron in ./
biblio.module - Implements hook_cron().
File
- includes/
biblio.keywords.inc, line 240
Code
function biblio_delete_orphan_keywords($force = FALSE) {
if (variable_get('biblio_keyword_orphan_autoclean', 0) || $force) {
$query = db_select('biblio_keyword', 'bk');
$active_kids = $query
->fields('bk', array(
'kid',
))
->groupBy('kid')
->execute()
->fetchCol();
$query = db_select('biblio_keyword_data', 'bkd');
$all_kids = $query
->fields('bkd', array(
'kid',
))
->groupBy('kid')
->execute()
->fetchCol();
$orphans = array_diff($all_kids, $active_kids);
if (!empty($orphans)) {
db_delete('biblio_keyword_data')
->condition('kid', $orphans, 'IN')
->execute();
}
}
return;
}