Index: modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc =================================================================== --- modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc (revision 585) +++ modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc (working copy) @@ -77,19 +77,38 @@ return FALSE; } - $placeholders = implode(', ', array_fill(0, sizeof($tids->value), '%d')); - $test = drupal_map_assoc($tids->value); $titles = array(); - $result = db_query("SELECT * FROM {term_data} WHERE tid IN ($placeholders)", $tids->value); - while ($term = db_fetch_object($result)) { - if ($vids && empty($vids[$term->vid])) { - return FALSE; + // check, if some tids already verified + static $validated_cache = array(); + foreach ($test as $tid) { + if (isset($validated_cache[$tid])) { + if ($validated_cache[$tid] === FALSE) { + return FALSE; + } + else { + $titles[] = $validated_cache[$tid]; + unset($test[$tid]); + } } + } - $titles[] = check_plain($term->name); - unset($test[$term->tid]); + + // if unverified tids left - verify them and cache results + if (count($test)) { + $placeholders = implode(', ', array_fill(0, count($test), '%d')); + + $result = db_query("SELECT * FROM {term_data} WHERE tid IN ($placeholders)", $test); + while ($term = db_fetch_object($result)) { + if ($vids && empty($vids[$term->vid])) { + $validated_cache[$term->tid] = FALSE; + return FALSE; + } + + $titles[] = $validated_cache[$term->tid] = check_plain($term->name); + unset($test[$term->tid]); + } } // Remove duplicate titles