3

I have a problem with Drupal 6.20.

Possibly after a PHP update, site stopped working. I get:

Notice: unserialize() [function.unserialize]: Error at offset 0 of 22765 bytes in /PATH/includes/cache.inc on line 33

This is the line:

$cache->data = unserialize($cache->data);

I would appreciate any help.

Shantha Kumara
  • 3,272
  • 4
  • 40
  • 52
user21897190
  • 31
  • 1
  • 1
  • 2
  • Is this coming out of a database? Perhaps some additional chars have appeared in the serialized string during the upgrade. As @Udo G says best to post the result of `var_dump($cache->data)` up here. – Treffynnon Apr 11 '11 at 15:46
  • See : http://stackoverflow.com/a/10152996/1226894 – Baba Oct 03 '12 at 15:18

4 Answers4

12

This problem will happen when you have Drupal 6.x running over PostgreSQL 9.0 because the bytea type was modified.
There are some suggested solutions here: http://postgresql.1045698.n5.nabble.com/Bytea-error-in-PostgreSQL-9-0-td3304087.html - (liking to Wayback Machine)

Running this on the database should fix it:

ALTER DATABASE databasename SET bytea_output='escape';
acm
  • 6,541
  • 3
  • 39
  • 44
4

Sounds like your Drupal cache has gotten corrupted.

The immediate solution would be to clear the caches. Three ways to clear the Drupal caches:

  1. Log in to the site with the admin password and select the flush caches option from the menu. This will obviously only be possible if you can get into the site in the first place.

  2. If you can't do that, you can use the Drush command-line utility to flush the cashes without having to go to the site.

  3. If you can't even get Drush to work (or you just don't want to install it), you can do it manually by going to the the database in your favourite MySQL tool, and emptying all the tables whose names start with the word "cache_".

The real question is why this would have happened in the first place. Sadly, I can't answer that, without a lot more info about your set up (and likely spending some time investigating too).

The danger is that even once you've cleared your cache, the same error could occur again, so even if you do get it working again, it would be a good idea to dig around a bit and see if you can find out the root cause.

My guess would be a rouge module that's got a bug has written bad data to the cache. You might want to check the drupal site and Google to check the modules you're using to see if there's any that have had similar behaviour reported.

Also, you mention a PHP update: Please let us know which versions of PHP you went from and to. There are known issues with some Drupal 6 modules in PHP 5.3, although the core does support it. See http://drupal.org/requirements for more info.

Spudley
  • 166,037
  • 39
  • 233
  • 307
  • Did everything you have said, but didnt work. I have to delete cache every time before clicking link, however in optins cache is disabled. Besides, there are many psql-related errors... – user21897190 Apr 11 '11 at 16:41
0

It is probably because of bad data inside of your array, you can fix it like this:

   $data= preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'",         $cache->data );
   $s_data= unserialize($data);
Sahin Yanlık
  • 1,171
  • 2
  • 11
  • 21
0

Try a var_dump($cache->data). It could be that PHP is adding escape sequences and/or quotes due to magic quotes or similar.

Udo G
  • 12,572
  • 13
  • 56
  • 89
  • I get a random sequence of letters/numbers stating with (its a really long string): string(22765) "x613 and it ends with: 3b7d" – user21897190 Apr 11 '11 at 15:44
  • To my knowledge any serialized data starts in the form "`X:n`" (and ends with `;` or `}`) where `X` is the type and `n` is the length. Examples `a:1`, `i:123`. Apparently the `$cache->data` value is completely wrong. You should check where that data comes from. – Udo G Apr 11 '11 at 15:49