locale.module breaks page if cache was emptied

suit4 - May 9, 2008 - 10:20
Project:Drupal
Version:5.7
Component:locale.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

I migrated a page from my development system to the live site, and therefore cleared the cache pages.

A bug in locale.module stops the page from working.

If the cache was cleared, there is no data in there, the there will be no $cache->data to unserialize.
If using http://drupal.org/project/backup_migrate, the cache tables are excluded from the db export by default, so the error occurs here, too.

Bug location: Line 185

<?php
     
if (!$cache) {
       
locale_refresh_cache();
       
$cache = cache_get("locale:$locale", 'cache');
      }
         
$locale_t = unserialize($cache->data); // The bug occurs here
...
?>

should read:

<?php
     
if (!$cache) {
       
locale_refresh_cache();
       
$cache = cache_get("locale:$locale", 'cache');
      }
      if(
$cache){
         
$locale_t = unserialize($cache->data);
      }
?>

I created a simple patch.

AttachmentSize
locale_dont_unserialize_nonexisting_cache.patch431 bytes

#1

drumm - June 7, 2008 - 01:06
Status:needs review» by design

I was unable to reproduce this behavior by doing 'DELETE FROM cache;' and loading pages while both logged in and not logged in. The 4 lines above this code should handle refreshing the cache before it is unserialized.

#2

suit4 - June 13, 2008 - 08:46

Apperently, the four lines to refresh the cache did not generata any content in $cache->data, which led to the error on my installation.
It was about manually clearing the cache from DB, so if this is not reproduceable, it might be just on my system.

I just tried, and today, I wasn't even able to reproduce it myself.

Maybe we just keep in mind, that there *might* be a problem here.

Sorry to bother you.

 
 

Drupal is a registered trademark of Dries Buytaert.