diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-10-02 11:07:45 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-10-02 11:07:45 -0700 |
commit | 9c42142614fdb292e231766dc778b959d74649c9 (patch) | |
tree | 3820edb20ffe2e1f95f70cf9777239d49937fa37 /modules/taxonomy | |
parent | faf20e4dc7f84414d34e1f5dbe32af632d72deca (diff) | |
download | brdo-9c42142614fdb292e231766dc778b959d74649c9.tar.gz brdo-9c42142614fdb292e231766dc778b959d74649c9.tar.bz2 |
Issue #1274674 by karschsp, pgrond, mdupont, aroq | Lars Toomre: Added static caching to taxonomy_vocabulary_get_names().
Diffstat (limited to 'modules/taxonomy')
-rw-r--r-- | modules/taxonomy/taxonomy.module | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index b7e962f89..df047e707 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -441,7 +441,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; } @@ -473,7 +473,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; } @@ -806,7 +806,7 @@ function taxonomy_term_is_page($term) { } /** - * Clear all static cache variables for terms.. + * Clear all static cache variables for terms. */ function taxonomy_terms_static_reset() { drupal_static_reset('taxonomy_term_count_nodes'); @@ -820,6 +820,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 @@ -836,7 +847,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; } |