[drupal-devel] [bug] Menu cache is not locale aware
Bèr Kessels
drupal-devel at drupal.org
Mon Jan 31 15:15:50 UTC 2005
Project: Drupal
Version: 4.5.0
Component: menu system
Category: bug reports
Priority: normal
Assigned to: chx
Reported by: chx
Updated by: Bèr Kessels
Status: patch
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)
Bèr Kessels
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.
--
View: http://drupal.org/node/13503
Edit: http://drupal.org/project/comments/add/13503
More information about the drupal-devel
mailing list