DRUPAL: how to get rid of unserialize errors d7

how to get rid of unserialize errors d7

For a while now I’ve been getting unserialize errors on my Drupal 7 site. For a while I thought that they only happened while someone was logged in since every time I tested the page with out logging in I never saw them. Example of error:

Notice: unserialize(): Error at offset 61 of 66 bytes in variable_initialize() 
(line 916 of /var/www/sitename/includes/bootstrap.inc).

So today I finally had a few minutes to work on trying to get rid of these annoying errors so I searched google for almost the same string above. And you know what came up? My web page. That means that everyone was seeing these unserialize errors. Most of the time these types of errors occur because when things are upgraded or migrated certain entries in the variables table do not get cleaned up when they are no longer needed. This is often the case if you have migrated your site from v5.x to v6.x to v7.x. (such as with my site.)

II think that the fastest way for you to fix this is to actually install a module called variablecheck. After you install it go to yourdomain.tld/admin/reports/variablecheck and see what the variables are that are causing the issues. In my case 4 out of 5 of the errors were an old version of the garland theme. Since I don’t use the Garland theme I felt quite safe just deleting the extra variables. You should really make that decision for yourself though. Make sure that you create a backup of your site and database before you go mucking around in the tables!

For a lot more information on this subject please check out the following post:
Use variable_initialize() against broken values – Notice: unserialize() and for some alternative ways to fix this problem check out the comment entitled A note for people experiencing this sort of problem