diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-10-11 16:04:29 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-10-11 16:04:29 +0000 |
commit | 65006002edba97c5ef1dcbaab0488d7dfeb1bed8 (patch) | |
tree | ad6cd5f5ba10ccaca6d6876f8001e8ba56280729 /modules/taxonomy/taxonomy.module | |
parent | da7f3a0ef021783c20f3c3fa4a1c57ed060dbfc2 (diff) | |
download | brdo-65006002edba97c5ef1dcbaab0488d7dfeb1bed8.tar.gz brdo-65006002edba97c5ef1dcbaab0488d7dfeb1bed8.tar.bz2 |
#162678 by robertDouglass, catch, and Damien Tournoud: Add static caching for
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r-- | modules/taxonomy/taxonomy.module | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 03cee16a4..b36325f5c 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -896,9 +896,25 @@ function taxonomy_get_synonyms($tid) { /** * Return the term object that has the given string as a synonym. + * + * @param $synonym + * The string to compare against. + * @param $reset + * Whether to reset the internal cache for this synonym. + * @return + * A term object, or FALSE if no matching term is found. */ -function taxonomy_get_synonym_root($synonym) { - return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $synonym)); +function taxonomy_get_synonym_root($synonym, $reset = FALSE) { + static $synonyms = array(); + + if ($reset) { + unset($synonyms[$synonym]); + } + + if (!isset($synonyms[$synonym])) { + $synonyms[$synonym] = db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = :name", array(':name' => $synonym))->fetch(); + } + return $synonyms[$synonym]; } /** |