memcache is not compatible with "i18n - menu"

ghostks - April 9, 2008 - 19:08
Project:Memcache API and Integration
Version:5.x-1.8
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

If using memcache + "i18n - menu" script dies with:
[09-Apr-2008 21:53:16] PHP Fatal error: Cannot use string offset as an array in /var/www/vhosts/www.destiny.lv/www/includes/menu.inc on line 1229

which corresponds to
// Menu items not in the DB get temporary negative IDs.
$temp_mid = min(array_keys($_menu['items'])) - 1;
$new_items = array();

foreach ($menu_item_list as $item) {
if (isset($item['callback'])) {
>>> $_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
if (isset($item['callback arguments'])) {

#1

firebus - April 9, 2008 - 20:26
Category:bug report» support request

is it that case that i18n menu does it's own caching?

if so, have you removed calls to serialize and unserialize

memcache handles serialization internally - if you look at the memcache patches, you'll see that the bulk of what they do is to remove calls to serialize and unserialize from core caching code. you'll need to do the same with any contrib module you use that caches

#2

ghostks - April 10, 2008 - 12:07

I've searched for the serialize/unserialize code in i18n, menu.inc and removed all instances but anyway the problem exists. I will try to investigate more and will notify if I'll find anything. The most interesting thing only i18n.menu sub module is broken, all others i18n.* are working perfectly.

#3

snufkin - May 31, 2008 - 01:29

same problem, with i18n here too.

#4

robertDouglass - July 18, 2008 - 19:53

Does the problem exist after removing serialize/unserialize AND clearing the caches (memcache and db)?

#5

robertDouglass - July 18, 2008 - 20:20

Also try with a memcache version greater than 1.7 (ie DRUPAL-5) because I think a patch that went in might solve this but need confirmation.

#6

robertDouglass - July 18, 2008 - 20:33
Priority:critical» normal

#7

pcambra - September 16, 2008 - 08:13

I am getting this error too in a multisite installation.

One of the sites, which has not i18n module installed, got the error, but it went away after running update.php.
The other site gets the error even after the update.php, if i clear the cache tables, the site runs good once, but the next time i get the error:

Fatal error: Cannot use string offset as an array in menu.inc on line 1229

Anyone can help me? (using drupal 5.10)

Thanks

#8

mikhailian - September 18, 2008 - 22:12
Version:5.x-1.7» 5.x-1.8

Got exactly the same problem, i18n-menu, 5.10,
Fatal error: Cannot use string offset as an array in menu.inc on line 1229
This configuration seems to be very popular ;-)

And it does not help changing in i18nmenu.module
cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
into
cache_set($cid, 'cache_menu', $_menu, time() + (60 * 60 * 24));
I still get the same error on line 1229

#9

mikhailian - September 18, 2008 - 22:24

Does the problem exist after removing serialize/unserialize AND clearing the caches (memcache and db)?

Gosh! Forgot to restart memcached!!!

The problem is solved with this simple patch to i18nmenu.module:

--- sites/all/modules/i18n/contrib/i18nmenu.module.orig 2008-09-19 00:03:48.000000000 +0200
+++ sites/all/modules/i18n/contrib/i18nmenu.module      2008-09-19 00:18:14.000000000 +0200
@@ -34,7 +34,7 @@
     }
   }
   // Update cache
-  cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
+  cache_set($cid, 'cache_menu', $_menu, time() + (60 * 60 * 24));
}

function i18nmenu_help($section = 'admin/help#i18nmenu' ) {

#10

snufkin - January 8, 2009 - 16:59

I haven't been able to reproduce the error with 5.x-1.8 so far.

 
 

Drupal is a registered trademark of Dries Buytaert.