Bug with language and access
sinasquax - September 22, 2009 - 10:20
| Project: | Tagadelic |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
Hello, there is a small bug with language and access because of not use of db_rewrite_sql in the module.
Also, i18n_taxonomy module checks if the sql has the {term_node} table and if yes, it doesn't alter the sql and the language check is not performed.
I have created a little patch to use db_rewrite_sql and a small trick to use term_node table without i18n_taxonomy find it, this patch handles correctly cache also.
Replace in tagadelic.module the tagadelic_get_weighted_tags function by :
<?php
function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) {
global $language;
// build the options so we can cache multiple versions
$options = implode($vids) .'_'. $steps .'_'. $size .'_'. $language->language;
// Check if the cache exists
$cache_name = 'tagadelic_cache_'. $options;
$cache = cache_get($cache_name);
// make sure cache has data
if (isset($cache->data)) {
$tags = $cache->data;
}
else {
if (!is_array($vids) || count($vids) == 0) {
return array();
}
$result = db_query_range(db_rewrite_sql('SELECT COUNT(*) AS count, t.tid, t.name, t.vid FROM {term_data} t INNER JOIN ' . db_prefix_tables('{term_node}') . ' n ON t.tid = n.tid WHERE t.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY t.tid, t.name, t.vid ORDER BY count DESC', 't'), $vids, 0, $size);
$tags = tagadelic_build_weighted_tags($result, $steps);
cache_set($cache_name, $tags, 'cache', CACHE_TEMPORARY);
}
return $tags;
}
?>
#1
already patched and partly committed in another thread. Thanks for your time on this.
#2
Yes this is a duplicate of http://drupal.org/node/141682 but don't forget to use the db_prefix_tables('{term_node}') trick to force i18n_taxonomy to rewrite sql for languages.
Thank you