You are here

function biblio_delete_orphan_keywords in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()
  2. 6 biblio.keywords.inc \biblio_delete_orphan_keywords()
  3. 7.2 includes/biblio.keywords.inc \biblio_delete_orphan_keywords()

Deletes orphaned keywords.

Deletion only occurs if the Drupal Variable "biblio_keyword_orphan_autoclean" is true OR if the $force argument is TRUE.

Parameters

bool $force: Forces deletion to occur even if autoclean is turned off.

Return value

int The number of orphans removed

2 calls to biblio_delete_orphan_keywords()
BiblioKeywordWebTestCase::testBiblioDeleteOrphanKeywords in tests/BiblioKeywordWebTestCase.test
biblio_cron in ./biblio.module
Implements hook_cron().

File

includes/biblio.keywords.inc, line 335
Contains all keyword related functions.

Code

function biblio_delete_orphan_keywords($force = FALSE) {
  $count = 0;
  if (variable_get('biblio_keyword_orphan_autoclean', 0) || $force) {
    $orphans = biblio_get_orphaned_keyword_ids();
    if (!empty($orphans)) {
      $count = db_delete('biblio_keyword_data')
        ->condition('kid', $orphans, 'IN')
        ->execute();
    }
  }
  return $count;
}