0

I use the E-Commerce Kickstart distribution. Almost always I get some error, every time I update and save any view.

screenshot

Please could anybody tell me what is causing this error, or give me some suggestions?

3 Answers 3

3

I have encountered the same issue and thus far to resolve but I found this article.

http://www.zyxware.com/articles/3337/drupal-errors-drupal-views-notice-unserialize-function-unserialize-error-at-offset-1009-of-1036-bytes-in-views-db-

so...i researched some more and found this solution. I added this line to bootstrap.inc

$data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $variable->value);  
$variables[$variable->name] = unserialize($data);

in the variable_init function

2

I know this was answered long ago, but this is to help out future Googlers.

All unserialize errors result from bad data in the database. Data stored in a serialized format will look like this:

s:9:"my string";
  • s - datatype (in this case string)
  • 9 - length of the data
  • "my string" - the data

In your case, the unserialize error is resulting from a view. If you have a database viewer/query program (i.e. phpmyadmin, dbForge Express, Navicat etc.) you can look at the views tables. You'll find that the only one containing serialized data is the views_display table; the display_options field contains serialized data. You can then execute a query such as the following:

SELECT vid, display_title, length(display_options)
FROM views_display
WHERE length(display_options)="11637"
  • vid, display_title are used to identify which record from the database is corrupted
  • display_options is the field containing serialized data, could be stored in database as longtext or a blob
  • views_display is the table we are searching as it is relevant to the error and contains serialized data
  • "11637" is the length of the data stored in the field and corresponds to the bigger number on the error

This particular query should return one result with the view id. You have the option to delete the view or try to repair the data.

To repair the data copy the serialized data into a text editor that will tell you what column/character you are on. In your case, you would go to column/character 10301 (the first number in the error) and see if you can identify a mismatch (wrong datatype, incorrect length, incorrect syntax). Copy the corrected data back into the database.

1
  • This is a great answer because it actually explains what is causing the problem, which clarifies why the accepted solution works. Commented Dec 5, 2019 at 2:30
2

Recently I faced the same problem. Solutions above didn't look very reliable to run on production.. Luckily I had a dev server where the view was working fine so I did the following:

Export the view:

  1. Login to my Drupal site dev server
  2. Go to /admin/structure/views and export the view from there
  3. Copy the exported view code

Import the view:

  1. On the drupal site that has the view issue, goto: /admin/structure/views/import
  2. And paste the view code there
  3. Make sure to check "Replace an existing view if one exists with the same name"
  4. Click Import
  5. Do not forget to save!

The imported view code solved the issue for me and hope that works for you as well!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.