[drupal-devel] [bug] Menu cache is not locale aware

moshe weitzman drupal-devel at drupal.org
Wed Feb 2 21:27:20 UTC 2005


 Project:      Drupal
-Version:      4.5.0
+Version:      cvs
 Component:    menu system
 Category:     bug reports
 Priority:     normal
 Assigned to:  chx
 Reported by:  chx
 Updated by:   moshe weitzman
-Status:       active
+Status:       patch

Aha! Makes sense now. +1 for this simple patch.


moshe weitzman



Previous comments:
------------------------------------------------------------------------

November 26, 2004 - 02:13 : chx

Attachment: http://drupal.org/files/issues/menu_locale.patch (522 bytes)

If you have a multi language site, and change languages, the menu is
already cached, thus it can not display the translated version. This
simple patch makes the menu cache locale aware. Do I need to file the
same patch against HEAD? 'Cos it applies, too.


------------------------------------------------------------------------

November 26, 2004 - 04:13 : Dries

Isn't it better to flush the menu cache when someone (or the admin)
switches languages?  Keeps the cache size down.


------------------------------------------------------------------------

November 26, 2004 - 06:20 : chx

There could be several points where the language is changed. i18n for
example displays a language selection block which lets you switch
anytime. Thus I think this solution is the best.


------------------------------------------------------------------------

November 26, 2004 - 07:26 : Goba

See also this issue [1], which is still (again) open. The locale is also
changed, when the admin changes it as the default on the admin
interface, and the menu cache needs to be flushed then, and the admin
needs to be redirected. I don't know how these problems are solved
currently, so I would only be able to submit a placebo patch to make
that issue pop up again...
[1] http://drupal.org/node/11312


------------------------------------------------------------------------

November 26, 2004 - 08:28 : Bèr Kessels

I solved it by adding some logic to the swithcer function in i18n:
when a language is switched the cache is flushed.
The negative side of this, is that if you have hundred various roles of
users reading English and one switching to German, the complete cahce is
flushed.
But then again, who has so many roles, that this might become an issue?


------------------------------------------------------------------------

November 27, 2004 - 04:59 : Dries

I just fixed bug 11312 [2].
I don't see what's wrong with invalidating the user's menu cache when
he or she switches language.  Just do:

<?php
cache_clear_all("menu:$user->uid");
?>


[2] http://drupal.org/node/11312


------------------------------------------------------------------------

January 30, 2005 - 14:26 : Jose A Reyero

This is needed also for i18n.
Invalidating cache is not a solution here, as we would need to do it
also for anonymous users.
So I think this is a simple solution and will work fine for both cases,
user/locale and i18n.


------------------------------------------------------------------------

January 31, 2005 - 10:15 : Bèr Kessels

I found out what is wrong with this:
Swithcing and cache are two completely differetn things:
The language is a per-session setting.
The cache is a per-role setting.
So any user can switch langauge on any moment, resulting in a cahce
that will get flushed on nearly every page-load. And since roles and
sessions are tow different thingsm we should not flush a role based
cache because a variable in the session changes.
The only correct option would be to have per-locale cache. (as per
Jose's patch)


------------------------------------------------------------------------

January 31, 2005 - 10:27 : Bèr Kessels

Correction,
It was not José that submitteed the patch for locale aware menu's but
Károly Négyesi, I got confused because José was the last to comment
on that patch.


------------------------------------------------------------------------

February 2, 2005 - 15:44 : moshe weitzman

i can't make heads or tails of this patch request. it seems that some
folks are confusing menu cache and page cache. and we don't even have a
role cache.
dries' question remains unanaswered. why can we not just rebuild a
user's menu cache when needed?


------------------------------------------------------------------------

February 2, 2005 - 16:17 : Jose A Reyero

/why can we not just rebuild a user's menu cache when needed?/
This way you cannot have menus in multiples languages for anonymous
users, unles they're not cached at all.


-- 
View: http://drupal.org/node/13503
Edit: http://drupal.org/project/comments/add/13503





More information about the drupal-devel mailing list