diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index d7a5e9a..c81b430 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -437,7 +437,7 @@ function taxonomy_vocabulary_save($vocabulary) { unset($vocabulary->original); cache_clear_all(); - entity_get_controller('taxonomy_vocabulary')->resetCache(array($vocabulary->vid)); + taxonomy_vocabulary_static_reset(array($vocabulary->vid)); return $status; } @@ -469,7 +469,7 @@ function taxonomy_vocabulary_delete($vid) { module_invoke_all('entity_delete', $vocabulary, 'taxonomy_vocabulary'); cache_clear_all(); - entity_get_controller('taxonomy_vocabulary')->resetCache(); + taxonomy_vocabulary_static_reset(); return SAVED_DELETED; } @@ -816,6 +816,17 @@ function taxonomy_terms_static_reset() { } /** + * Clear all static cache variables for vocabularies. + * + * @param $ids + * An array of ids to reset in entity controller cache. + */ +function taxonomy_vocabulary_static_reset($ids = NULL) { + drupal_static_reset('taxonomy_vocabulary_get_names'); + entity_get_controller('taxonomy_vocabulary')->resetCache($ids); +} + +/** * Return an array of all vocabulary objects. * * @return @@ -832,7 +843,12 @@ function taxonomy_get_vocabularies() { * An array of vocabulary ids, names, machine names, keyed by machine name. */ function taxonomy_vocabulary_get_names() { - $names = db_query('SELECT name, machine_name, vid FROM {taxonomy_vocabulary}')->fetchAllAssoc('machine_name'); + $names = &drupal_static(__FUNCTION__); + + if (!isset($names)) { + $names = db_query('SELECT name, machine_name, vid FROM {taxonomy_vocabulary}')->fetchAllAssoc('machine_name'); + } + return $names; }