function biblio_delete_orphan_authors in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 includes/biblio.contributors.inc \biblio_delete_orphan_authors()
- 6 biblio.contributors.inc \biblio_delete_orphan_authors()
- 7 includes/biblio.contributors.inc \biblio_delete_orphan_authors()
2 calls to biblio_delete_orphan_authors()
- BiblioContributorUnitTest::testBiblioDeleteOrphanAuthors in tests/
contributor.test - biblio_cron in ./
biblio.module - Implements hook_cron().
File
- includes/
biblio.contributors.inc, line 175
Code
function biblio_delete_orphan_authors($force = FALSE) {
if (variable_get('biblio_auto_orphaned_author_delete', 0) || $force) {
$query = db_select('biblio_contributor', 'bc');
$active_cids = $query
->fields('bc', array(
'cid',
))
->groupBy('cid')
->execute()
->fetchCol();
$query = db_select('biblio_contributor_data', 'bcd');
$all_cids = $query
->fields('bcd', array(
'cid',
))
->groupBy('cid')
->execute()
->fetchCol();
$orphans = array_diff($all_cids, $active_cids);
if (!empty($orphans)) {
db_delete('biblio_contributor_data')
->condition('cid', $orphans, 'IN')
->execute();
}
}
}