Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.429 diff -u -p -r1.429 taxonomy.module --- modules/taxonomy/taxonomy.module 24 Sep 2008 18:42:00 -0000 1.429 +++ modules/taxonomy/taxonomy.module 24 Sep 2008 22:33:28 -0000 @@ -893,9 +893,29 @@ 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. + * + * @return + * An array of synonyms. */ -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 ($synonym == '') { + return NULL; + } + if (empty($synonyms[$synonym])) { + $synonyms[$synonym] = (object)db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $synonym)); + } + return $synonyms[$synonym]; } /**