[drupal-devel] [bug] Menu cache is not locale aware
killes
drupal-devel at drupal.org
Sun Mar 13 22:10:22 UTC 2005
Issue status update for http://drupal.org/node/13503
Project: Drupal
Version: cvs
Component: menu system
Category: bug reports
Priority: normal
Assigned to: chx
Reported by: chx
Updated by: killes at www.drop.org
Status: patch
I agree, this should get patched. Still applies.
killes at www.drop.org
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.
More information about the drupal-devel
mailing list