Dear friends,
I read the recent thread about supporting of localizer. I don't use it so I dont know. I use I18N ("Internationalization"). And, seem that also with Internationalization, Tagadelic seem unable to filter just the current language term.
But, with I18N, I think it's easy to solve the problem. I just had to modify tagadelic.module, adding a call to "db_rewrite_sql" while using the select - and, as far as I can see, it works - now tagadelic (drupal 5.1) seem able to show only the current language terms.
My patch proposal is something like this:
FROM:
$result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
TO:
$result = db_query_range(db_rewrite_sql('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC'), $vids, 0, $size);
I also tried the patched module on a drupal 5.1 site where I18N is not active, and tagadelic works fine there too.
So - if somebody else can test it, maybe it could be added to the source? Would be great to have clouds translated...
Thanks to all!
FB
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | tagadelic.access+cache.patch | 1.44 KB | wuf31 |
| #3 | tagadelic_11.patch | 937 bytes | francoud |
Comments
Comment #1
francoud commented(the same modification should be done in the tagadelic_views module....)
Comment #2
Bèr Kessels commentedCan you make a real patch from this? http://drupal.org/diffandatch
Comment #3
francoud commentedOK - I'm not expert of doing patches :-) so I am not sure this is done correctly... can u test or tell me if I do some mistake?
Anyway - this is my simple patch proposal for tagadelic.module. If it's ok I'll do the same with tagadelic_views.module...
Comment #4
z.stolar commentedThanks!
it worked for me with no visible issues.
Comment #5
trogie commentedworks good for me too!
Unfortunately not included in the latest release...
Comment #6
Bèr Kessels commentedI am a bit reluctant to simply add the db_rewrite_sql without extensive testing.
Problem is that the query is rather complex. And I know for certain that some access cotnrol modules, such as organic groups, have trouble rewriting complex queries.
It needs more testing with several complex access modules
Taxonomy_access_lite
Organic groups
.. fill in your own.
Bèr
Comment #7
Bèr Kessels commentedComment #8
Bèr Kessels commentedAlso look at http://drupal.org/node/62840, wich will probably solve this i18n issue.
Comment #9
trogie commentedI have been using db_rewrite_sql with rather more complex queries (extra (left/right) joins etc), taxonomy_acces and i18n. It never caused any problems.
I'm not using organic groups yet but i'm very much sure they work with db_rewrite_sql too to add extra clauses to the queries.
Comment #10
francoud commentedI used "my" patch for long time and honestly I didnt have problems. Of course I didnt test it with "all" modules. :)
Comment #11
john morahan commentedTested and working for me with http://drupal.org/project/content_access
Comment #12
john morahan commentedBetter title.
It's a little odd that it uses a node-based rather than a term-based rewrite, but I suppose it makes sense as most (all?) taxonomy-based access control modules also restrict access to nodes with those tags; also a term-based rewrite would give inaccurate tag sizes by including inaccessible nodes in the count.
Comment #13
Bèr Kessels commentedhttp://drupal.org/node/84095 Contains some changes to the caching. We need that in this patch too.
Comment #14
wuf31 commented@Ber : I'm not sure if this is the kind of implode you want.
I've tested this patch with Taxonomy Access Control, works fine.
Though the cache is set per user role, so if you're using access control per user level.. the caching may not work properly. I suspect that TAC Lite falls into this category. Anybody can confirm ?
Guys, please review..
Comment #15
john morahan commentedI don't know about TAC Lite, but OG's access control is per-group, not per-role.
Comment #16
Bèr Kessels commented... and many more ways of making access persmissions.
TRue: caching with Roles is far from perfect and we need to find another way.
Idea: db_rewrite_sql the query, hash it, and use that as cache-key.
If it exists, then continue, if not, then execute that SQL string.
It measn that we have to call some rather expensive calls, such as the db_rewrite and so, but at least it is flexible and allows for any type of access, yet still allow some form of caching on the most expensive part.
Bèr
Comment #17
wuf31 commentedCustom Pagers deal with this issue by storing the cache in the $_SESSION variables.
Perhaps this is the best solution?
db_rewrite_sql may not see it into drupal 7.
Better ideas ?
Comment #18
john morahan commentedAnother possibility could be to add the user id to the cache key.
Comment #19
geodaniel commentedCaching by UID seems like a sensible way of doing this. We would need to make sure their cache was invalidated every time their access rights changed though.
Comment #20
xamountok, for the all the people having issues with tags showing up for unpublished nodes, or tags for nodes that users should not see, you can use the tagadelic_views module to accomplish the same default block that comes with the tagadelic module, but in the filter for the view, just set what you want to filter/show by.
I use the workflow module so tagadelic views came in very handy to show only "published" articles.
Bèr Kessels, after searching the issue queue, I saw a couple duplicate posts with this issue and it's probably (at least to me) a very important issue for users not to see tags for nodes they should not see.
So maybe you can mention tagadelic_views will solve that problem in the duplicated issues.
I am not sure of the performance impact with using tagadelic_views though...anyone?
ps maybe it might also be a good idea to mention this issue on the module's page or in the readme file (tags showing up for non-published nodes etc).
Comment #21
Bèr Kessels commentedI am not all too happy with the concept of caching on a parameter that *we* choose.
Tagadelic knows nothing about the module that implements the access-control, as it should be.
So we may (and by rule of law, hence *will*) make false assumptions and cache the wrong data. Resulting in people still seeing tags they should not see, or people not seeing tags that they shoud see.
I am leaning towards a method where we simply disable caching alltogether, when there is a module that implements db_rewrite_sql.
Another option could be to create the SQL, running it trough db_rewrite_sql and hashing that. This hash can be used as key for the cache.
This may, in some situations, lead to a huge amount of cache-items, but will, in general work as it does now, with the same amount of cached-entries.
Can anyone look at the latter option? And see if that gives us a nice lead?
Comment #22
hctomwill there be a new release soon for the 6.x branch? I really need this feature in order to be able to display language-dependant tagclouds :-(
Comment #23
Bèr Kessels commented@hctom: if you really need this, then please join the effort.
I don't need it, so I have no incentive to fix this. You seem to need it, so go ahead: and participate! And thou shalt be rewarded with Kudos as far as the eye reaches.
Comment #24
Bèr Kessels commentedClosing "needs work" that has been open for a long time, without anyone working on it.
Comment #25
Bèr Kessels commentedComment #26
pfrenssenThis issue has been fixed in #250818: SQL accounting for revision history and i18n.
This message as a courtesy to people looking through the issue queue. Several issues are marked as duplicates of this, and the "won't fix" status was misleading since this issue is actually fixed.