Wow - any clues why I am getting this error?

Notice: unserialize() [function.unserialize]: Error at offset 36 of 43 bytes in variable_initialize() (line 749 of /var/www/vhosts/

it happens intermittantly, but often, if you go to there is a good chance you
will see it right there on the front page :(

I've done some searching and it looks like I may have database corruption - all that I found about it is on
Drupal 6 - they talk about making changes to to identify the corruption and fix manually -
Someone else suggested that I do a
SELECT name, LENGTH( value ) , value
FROM variable
WHERE LENGTH( value ) = "43"

which came up with a variable called "update_notify_emails"

but I am not sure what to do next can somebody help a brotha out?

Many thanks in advance!


oregonwebsiteservices’s picture

Please help?!?!

Steven Jones’s picture

Category: bug » support

What may have happened is that the variable value has been corrupted in the database in some way, try removing it from the database by either running the following PHP code (with the devel module) or SQL query.



DELETE FROM variable WHERE name = 'update_notify_emails'

oregonwebsiteservices’s picture

Status: Active » Fixed

I did what you suggested and it seems to have resolved the issue - many thanks!

dilnix’s picture

Status: Fixed » Active

I having some similar
Notice: unserialize() [function.unserialize]: Error at offset 2 of 8 bytes in variable_initialize() (line 749 of /home/h29638/data/www/
So just tried to use SQL query
DELETE FROM variable WHERE name = 'update_notify_emails'
And have no effect, notice is prolongs further. May be my problem is some different??
Help me to find a fix for this please...

Steven Jones’s picture

Status: Active » Fixed

It will be a different variable that is causing your issue, run:

SELECT name, LENGTH( value ) , value
FROM variable
WHERE LENGTH( value ) = "8"

To find out the potential variables that might be causing the issue, find the one that is broken, and delete it from the database.

oregonwebsiteservices’s picture

Steven you da man!

Starminder’s picture

Title: unserialize: Error at offset 36 of 43 bytes in variable_initialize() line 749 of » unserialize: Error at offset 446 of 23435 bytes in variable_initialize()

Similar problem here:

•Notice: unserialize() [function.unserialize]: Error at offset 446 of 23435 bytes in variable_initialize() (line 748 of /home/hoslot5/public_html/includes/
•Notice: unserialize() [function.unserialize]: Error at offset 44 of 45 bytes in variable_initialize() (line 748 of /home/hoslot5/public_html/includes/

Starminder’s picture

Status: Fixed » Needs work
Steven Jones’s picture

Status: Needs work » Fixed

Right, let's just provide a simple step-by-step guide:

If you're getting an error like this:

Notice: unserialize() [function.unserialize]: Error at offset X of Y bytes in variable_initialize()...

Then the important number is: Y.

Run this SQL query (replacing Y with the number from the error message):

SELECT name, LENGTH( value ) , value
FROM variable
WHERE LENGTH( value ) = Y

Then, if there are multiple records returned try to identify the one causing the issue. Once you have the name of the variable causing the issue, run, replacing NAME with the name you have found:

DELETE FROM variable WHERE name = 'NAME'

Starminder’s picture

Thanks for the explanation, worked like a charm!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bryancasler’s picture

Fantastic new module out that takes care of all these notices

CarbonPig’s picture

#9 @Steven Jones

Thanks for the clear instructions - seems to have worked.

The only question I have is this:

I got about 5 records. I wasn't sure which one was "causing the issue", so I deleted all of them using the provided command.

Could this be an issue later?



probocop’s picture

@Steven Jones - After much head scratching with this issue, I stumbled across this thread and it worked a treat. Thanks alot!

avoura’s picture

Thanks for the link, I had a similar problem, installed this module (variablecheck) and it found an old variable for an earlier version of the Zen theme, which I had used before using a different theme and then upgrading Drupal from 6.x to 7.x

leanderl’s picture

Thanks! This problem has been plaguing me for six months -- now I could finally solve it with the Variable Check module and deleting the "bad" variables. Perfect!

GiorgosK’s picture

#9 worked great

Marcus Ledergerber’s picture

Issue tags: +variable check

#9 solved this issue. And, the Variable Check module makes it super easy.


drpl’s picture


devildog’s picture

great explanation by Steven Jones at #9. Thanks!

jillslocum’s picture

Using Drupal 7 and Sqlite3, I am getting this same unserialize error. I've isolated the variables causing it. Each is an array of blobs with strings, and each contains a line feed character, '0a'. There are no other values in the variable table which contain line feeds, so I am assuming that these characters are causing the problem. Other answers here seem to suggest deleting these variables, but as far as I can tell they are used by the web site software. Why would I want to do this? Also, what would VariableCheck do to solve this problem? Thanks for any help people can give.

dark_kz’s picture

openmode’s picture

DELETE FROM variable WHERE name = 'taxonomy_xml_url'

esmitex’s picture

Issue summary: View changes

I have a similar issue, I get the following error when adding a new content with a matrix field:

Notice : unserialize(): Error at offset 401 of 3920 bytes in matrix_field_widget_form() (line 202 in /homepages/45/d444012100/htdocs/smq/sites/all/modules/matrix/matrix.module).

slevino’s picture

I received this error after (during?) a core update of drupal.

Notice: unserialize(): Error at offset 11 of 35 bytes in variable_initialize() (line936 of /var/www/vhosts/3/101684/webspace/siteapps/Drupal-12836/htdocs/includes/

I installed the variable check module ( which identified the bad value:

update_notify_emails a:1:{i:0;s:26:"";}
But this is indicating that the function is expecting an array, not just a string so I couldn't just set a new value, and when I checked the value table in the mysql db the data value was a blob and I couldn't edit it. Not knowing what module set that value and what might break if I simply deleted it I decided to try "re-setting" the array to clear it out.

Google told me that "update_notify_emails" is called in the update module into modules, clicked congfigure for Update Manager
and edited the value for "E-mail addresses to notify when updates are available" (mine was blank). Since the error indicated it was expecting both an int and a string I also flipped the setting on "Only security updates" so that value was passed in as well. Clicked save and error went away.

leymannx’s picture

Yes #25!!! That's it!!! So simple ...

leymannx’s picture

3 month later. Same problem, slightly different cause. This time #9 helped me to spot it.
So inside theme_preprocess_page (template.php) I checked

  // replace XXINTEGER_HEREXX with the 2nd bytes value of your error notice
  $result = db_query('SELECT name, LENGTH( value ) , value
    FROM variable
  foreach ($result as $record) {

The dpm() returned me name == webform_default_from_name I then tried to db_delete, what didn't work. So I went to check Webform module settings and simply filled in all 'from' fields again. Error gone.

memcinto’s picture

Sadly, in our case, after moving a site to a new server (and going from standalone to multisite), and getting these errors:

Notice: unserialize(): Error at offset 1776 of 1808 bytes in EntityAPIController->load() (line 261 of /xxx/xxx/xxx/xxx/xxx/xxx/sites/all/modules/contrib/entity/includes/
Notice: unserialize(): Error at offset 2073 of 2105 bytes in EntityAPIController->load() (line 261 of /xxx/xxx/xxx/xxx/xxx/xxx/sites/all/modules/contrib/entity/includes/

the module "variablecheck" found "No invalid variables found"

Trying the direct query also returned no rows.

Adrião Neves’s picture

I also had an identical issue, and after finding out which variable was causing the error, in my case the string size was wrong, I updated the value and until now no more error. Most cases will have a value harder to fix.

kcfinder_upload_url | 36 | s:24:"example/uploads";
kcfinder_upload_url | 36 | s:15:"example/uploads";