Commit f5085c00 authored by catch's avatar catch

Issue #1274674 by karschsp, pgrond, mdupont, aroq: Added static caching to...

Issue #1274674 by karschsp, pgrond, mdupont, aroq: Added static caching to taxonomy_vocabulary_get_names().
parent 94e0c231
......@@ -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;
}
......@@ -815,6 +815,17 @@ function taxonomy_terms_static_reset() {
entity_get_controller('taxonomy_term')->resetCache();
}
/**
* 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.
*
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment