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

chx drupal-devel at drupal.org
Mon Mar 28 23:17:41 UTC 2005


Issue status update for http://drupal.org/node/13503

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

I have bumped this to critical status, I feel this very important, very
simple, non evasive.


chx



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

November 26, 2004 - 08: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 - 10: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 - 12: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 - 13: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 - 14: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 - 10: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 - 20: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 - 16: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 - 16: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 - 21: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 - 22: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.


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

February 2, 2005 - 22:27 : moshe weitzman

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


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

March 13, 2005 - 23:10 : killes at www.drop.org

I agree, this should get patched. Still applies.


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

March 14, 2005 - 00:24 : stefan nagtegaal

Tested against 4.6 RC I and works perfectly!
+1 for applying this bug-fix..


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

March 14, 2005 - 14:23 : Bèr Kessels

Josés latest comment tels in much less wording what i tried to explain
too.
Still +1 from me, since with i18n (and other possible language modules)
you cannot simply flush the cache.
This patch is simple, clean and only adds one row per language to your
cache table. That cannot be a problem, now, can it?


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

March 26, 2005 - 20:56 : elfur

I'd like to +1 this change.
I too have a dual language website where changing the language in the
language block does not change the language of the navigation block,
while all other blocks change.
But what also happens is that on my user profile page I can select
which language are assigned to the user, and when I swithced that the
first time, the language of the navigation block got switched to the
selected language of the web - however when I changed that user profile
setting back to my preferred language, the navigation block does not
change back with it. Infact, when I then change the language in the
language block, the navigation does not change back to what it was
stuck at before *shrug*.
I hope that does make sense to anyone.
/me heads over to try that patch to see if it fixes this annoying
"feature"
thanks
elfur
http://elfur.is





More information about the drupal-devel mailing list