diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-12-05 22:18:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-12-05 22:18:46 +0000 |
commit | 58b0235a72859aa433d743a9f284504f24664857 (patch) | |
tree | 524132d2e7ca157baa1059117244a5b27b1f51fb /modules/taxonomy/taxonomy.api.php | |
parent | 0b06c68b988410c49c9f4ffbf8c3160d4e9da2c7 (diff) | |
download | brdo-58b0235a72859aa433d743a9f284504f24664857.tar.gz brdo-58b0235a72859aa433d743a9f284504f24664857.tar.bz2 |
- Patch #324313 by catch et al: load multiple nodes and terms at once.
Diffstat (limited to 'modules/taxonomy/taxonomy.api.php')
-rw-r--r-- | modules/taxonomy/taxonomy.api.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/taxonomy/taxonomy.api.php b/modules/taxonomy/taxonomy.api.php index 553386000..fd6d2bcd7 100644 --- a/modules/taxonomy/taxonomy.api.php +++ b/modules/taxonomy/taxonomy.api.php @@ -74,12 +74,21 @@ function hook_taxonomy_vocabulary_delete($vocabulary) { * * Modules implementing this hook can act on the term object returned by * taxonomy_term_load(). + * For performance reasons, information to be added to term objects should be + * loaded in a single query for all terms where possible. * - * @param $term - * A taxonomy term object. + * Since terms are stored and retrieved from cache during a page request, avoid + * altering properties provided by the {term_data} table, since this may + * affect the way results are loaded from cache in subsequent calls. + * + * @param $terms + * An array of term objects, indexed by tid. */ -function hook_taxonomy_term_load($term) { - $term->synonyms = taxonomy_get_synonyms($term->tid); +function hook_taxonomy_term_load($terms) { + $result = db_query('SELECT tid, foo FROM {mytable} WHERE tid IN (' . db_placeholders(array_keys($terms)) . ')', array_keys($terms)); + foreach ($result as $record) { + $terms[$record->tid]->foo = $record->foo; + } } /** |