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!
:)
Add new comment