Fixing Drupal error: Notice: Undefined offset: 1 in views_block_view()
Published by emacstheviking on Tue, 06/14/2011 - 21:43
Damn this was a pain. For more heads up go here: http://drupal.org/node/1065942
It's caused by stale records in the block table that then fail to resolve. There's plenty of reading material out there and suggested fixes etc. that I am sure work but once I knew what the problem was I applied *my process* for all Drupal problems like this.
- Find the code that issues the message..
- Trap the code and drupal_set_message() the offending item
- Use that information to fix-up the database / code as required.
Here's how the fix works for this particular problem. In my case I edited views.module, line 569, here's the code that was causing the notice to be show:
list($name, $display_id) = explode('-', $delta);
and here is what I added to the code to find out what the duff delta in question was...
if (count(explode('-',$delta)) == 1) {
drupal_set_message($delta);
}
list($name, $display_id) = explode('-', $delta);
Simples. All I did then was refresh the page, take a note of hash value that was displayed and then cutting-and-pasting it into a command line MySQL session I issued this query:
mysql> delete from block where delta = 'd98a0bfa5a33e7d8bab0fc0670bdc9fd'; Query OK, 4 rows affected (0.01 sec)
Which took out all four problem pages at once.
Job done.
Don't forget to remove the line of code just in case it upsets users!
:)
Comments
Monster Beats by Dre
That’s an appealing stance you took. When I look at the title, I right away had a disagreement of opinion, but I do see your side.
Monster beats by dre|beats by dre headphones|Monster beats by dre headphones
Thank you !
Great "how to" ! You solved my issue in an impressive way ! I'm a newbie and still did it ! Thanks.
thank you
Thank you for this. I would never figured it out by myself.
Thanks!
Thanks for this - fixed the problem nice and easy!
Thank you thank you!
thank you!
fix for Drupal error: Notice: Undefined offset...
Works like a charm. Thanks very much!
Saved my day
You saved my day. Thanks for sharing this!
thanks for providing this
thanks for providing this quick solution. this error message drove me nuts.
Excellent!
Your suggested fix worked beautifully when I ran into this same error.
Being new to Drupal, this was also fairly educational as to how things work underneath.
Thank you very much for posting such a concise, good fix.
Thx, it works.
Thx, it works.
fixed in current views-dev
Hi
This indeed fixed the error. But it was caused by a bug in views, even on rc1. This is now fixed in views dev.
The issue for the bug is here: http://drupal.org/node/1151032
The patch is this one: http://drupal.org/files/issues/1151032-block-update.patch
Well done, very useful,
Well done, very useful, thanks a lot! :)
You saved my life.
Thanks for your awesome tips.
Thanks
You saved me hours of debugging with this simple SQL query! Thank you!
It worked immediately, but just in case it didn't, I actually ran a SELECT statement before your DELETE statement. I didn't need to revert, but safety first, am I right? :)
Add new comment