I'm filing this as a bug report since leaving stale data in the block table eventually leads to a notice in views.module.

How to reproduce:
- In a view, create a block display with a long machine name so that {view-name}-{block_name} is longer than 32 chars. (thisisaverylongmachineforaviewsblock should work as machine name).
- assign this block to be displayed in a region of your theme (at this point there should be a views hash delta in the block table).
- rename the views block to something else (the length does not matter)
- visit the blocks page
- visit the homepage or any page on your site where the old block was set to appear, and note the message:

Error message
Notice: Undefined offset: 1 in views_block_view() (line 517 of /sites/all/modules/views/views.module).

When renaming the machine name, views discards the old hash from its views_block_hashes variable, but the old hash remains in the block table, and Drupal excepts to find information on a block with this old hash. Views should remove the old hash record from the block table, or rename it to the new hash so as to preserve any block settings which were made to this block.

Comments

dawehner’s picture

Was this the case in d6, too?

If yes this has be fixed there, too.

scor’s picture

haven't tried in D6, but thought that (if views works the same way as core), it ought to be fixed in D7 first and then backported to D6 if this bug report also applies to D6.

dawehner’s picture

Views has currently another development workflow. Things are fixed against 6.x-3.x and then get ported to d7.

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev

So

scor’s picture

I wasn't able to reproduce in D6. With 6.x-3.0-alpha3, the old hash record in the blocks table is removed and a new record with the new hash (and with a new bid) is created.

mgifford’s picture

I got the error in D7. Not sure why the version was switched down to D6.

dawehner’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Move back to 7.x-3.x

scor’s picture

Title: Renaming a block display machine name leaves stable records in the block table » Renaming a block display machine name leaves stale records in the block table
GarbageXAY1979’s picture

I am getting this error on my Windows (local) machine. On the server I don't because I have no error reporting enabled - but on Windows it's all error reporting.

What is the fix for this? I dumped the $delta variable on line 519 and received the following:

[Sun Jan 09 17:55:02 2011] [error] [client 127.0.0.1] ebce8566fbf6ae24afdc63dcbe167c0b, referer: http://mywebsite.local/
[Sun Jan 09 17:55:02 2011] [error] [client 127.0.0.1] latest_blog_entries-block_1, referer: http://mywebsite.local/

Looking at the code quickly it's seems as though the MD5 hash should be used as a key to determine the view name???

In any case I tried clearing my Views cache and I am still getting this error. Any fix? Supressing the error in code or disabling error reporting isn't really an option. Any ideas???

Cheers,
Alex

scor’s picture

@alex: you can manually delete the stale hash records from the block table.

GarbageXAY1979’s picture

I was afraid of that :p

Will do thanks for the reply :)

Blooniverse’s picture

God save queen 'phpMyAdmin'. Good hint, thank you @scor:

[...] manually delete the stale hash records from the block table.

dawehner’s picture

Status: Active » Needs work
StatusFileSize
new4.92 KB

Here is a somehow first version.

I'm pretty sure this issue exist in d6, too. Perhaps the notice is not displayed but the block has to be moved, too.

scor’s picture

+++ plugins/views_plugin_display_block.inc	11 Jan 2011 22:24:18 -0000
@@ -157,7 +157,10 @@ class views_plugin_display_block extends
     parent::options_submit($form, $form_state);
+        $section = $form_state['section'];
     switch ($form_state['section']) {

The indentation looks odd. Also, where is the $section variable used?

dawehner’s picture

Oh i c&p some code and removed it later. It seems to be that i missed this part.

David D’s picture

I got this error as well (in D7), and was able to fix it by deleting the record from the block table. Hard to be sure which record(s) I needed to remove, but I eventually got it, apparently without bricking anything. Thanks for the tip!

007pig’s picture

subscribe

Renegadez’s picture

Notice: Undefined offset: 1 in views_block_view() line 519 of /home/mysite/public_html/sites/all/modules/views/views.module).

How do I know which record to delete this error is filling up my log files Thanks for any help!

David D’s picture

@Renegadez, look for the record(s) that show the block machine name as it was before you renamed it.

Renegadez’s picture

I look in every list in PHPMYADMIN in all the block section this is the ponly one that has any VIEWS this is under block_role I did not find anything that said machine_name

module The block’s origin module, from block.module. delta The block’s unique delta within module, from block.delta. rid The user’s role ID from users_roles.rid.
Edit Delete views 42e444a63ac6d5ea96dbe276a95f3e9 2
Edit Delete views 5ccbaaf5f955b62d9cae0308418e404 2
Edit Delete devel_node_access dna_user 3
Edit Delete shortcut shortcuts 3
Edit Delete views 42e444a63ac6d5ea96dbe276a95f3e9 3
Edit Delete views 5ccbaaf5f955b62d9cae0308418e404 3
Edit Delete shortcut shortcuts 4
Edit Delete views 42e444a63ac6d5ea96dbe276a95f3e9 4
Edit Delete views 5ccbaaf5f955b62d9cae0308418e404 4

David D’s picture

This has nothing to do with Views, really. Views is just the UI you happen to be using to edit the block name. The Block table is what you want. The field is delta (that's the machine name).

mgvanmiddelkoop’s picture

This thread helped me just perfect - I have encountered the same bug, too, even though I did not use a long view name. I had just deleted a view and did not unassign that view to a block first. That seems to have the same effect.

I have applied the same workaround by just deleting the stale records from the blocks table, and now the error message is gone. Thanks a lot!

Renegadez’s picture

Ok thanks but I dont think i have enough experience in myphpadmin to find what i need i do not want to delete the wrong line thanks tho!

dthomas731’s picture

Same as with mgvanmiddelkoop this tread helped. I deleted the view before I unassigned it from a block and got the error message.

alexbern’s picture

@Renegadez,
I found the stale record in block -> last entry. this had an unusual (compared to others in this entity) delta name: a row of numbers..

i tried deleting it and it was successgfull..
If you not be sure you can edit the record and say "save and return" before you delete it. So you should eb able to rearrange...

cheers alex

Renegadez’s picture

I will give it a whirl i think i saw an export table i can do brfore I go deleting stuff Thanks!!

yskel’s picture

Happened to me on D7, too. I hadn't removed any blocks, but I had added a couple with longer names (~30). In my case, I was filtering blocks by Drupal path, so identifying that paths that were firing the error allowed me to pinpoint and manually delete the problem rows in drupal.block. Now that I'm here, about half of the blocks that I've created have a delta that is all hex digits, not text, like the name has been hashed - should this be happening? Why is it happening for some block names, and not others?

David D’s picture

I saw the hash or hash-like deltas as well, and if I recall correctly those were the problem ones that I removed from my db. I think it may happen if you create a new block display in a view, save it, and then change the block name after having saved it. Or maybe you have to actually load the block or do something with it in the regular block UI before you rename it. My takeaway is that (until this might get fixed in Views, if that's were the bug is) I should always edit the block name immediately after adding the new block display. Or failing that, maybe just live with the default.

tax14’s picture

I too had the same issue. I was working on views and creating/cloning new views, and all of sudden started getting error:

Notice: Undefined offset: 1 in views_block_view() (line 519 of C:\xampp\htdocs\drupal7\sites\all\modules\views\views.module).

I deleted all views and blocks but was still getting the error. I even applied the patch mentioned at #14 but no help. Finally deleted all view and blocks related records that I created from the block and block_custom tables and the the problem disappeared. I believe there is some serious problem that should be fixed.

reptilex’s picture

same here. I haven't figured what exactly causes the error. I can confirm it has to do with the delta name in the block table and renaming.
The notice comes from when the delta tries to be exploded by '-' and cannot because it is not view-block-myblockname but d38dd34455d4e6206e6ae4c739266a5c. When I change the name of the view in the ui a new record to the block table is added and there is no renaming of the one I had. Strangely enough I don't see three blocks in the block editing table.

cartagena’s picture

Thanks, got the error and deleted the rows in block table and OK for now. I appreciate the help!--I got the error when I deleted views and content types that were part of blocks. So, rather than changing names I deleted them.

triskele’s picture

Just want to add that I'm experiencing this issue too. Makes for some ugly class/id names, let me tell you.

Screenack’s picture

Version: Views 7.x-3.0-alpha1

Here's how I fixed this issue when it hit me (my actions were based on the above feedback, very helpful -- thanks!)

  1. Back up the database!
  2. View the block table and look at the most recently added entries
  3. Delete the views > block that was affected
  4. Deleted the most recently added block row from the latest one on back.
  5. Refresh the affected page
  6. If error still shows, repeat the above two steps until error is gone

This approach worked for me as I had not done any additional block themeing when I caught the error. I'm not sure this approach will work otherwise.

GerdC’s picture

subscribe

GerdC’s picture

I created this error by
1. define a block in Structure -> Views
2. assign this block in Structure -> Blocks to a region
3. delete the block in Structure -> Views

I found this leaves an entry in the block table in the database with module = 'views'.
Deleting this entry from the database solves the problem for me. I made no extensive tests that this doesn't create other problems.
Back up your database before you think about trying this :-)

Hope this helps...
Gerd

HunterT’s picture

I keep getting the error "Notice: Undefined offset: 1 in views_block_view() (line 579 of"

After reading some of these posts I realized that it is because I changed the machine name of a couple of my blocks. I tried to completely uninstall views and ctools modules, then reinstall them and re create every single one of my views just to get rid of this error. I know there is probably an easier way to get rid of the error but I'd rather just recreate all of my views.

After uninstalling, reinstalling, I went to create the first view and only edited the master page and my site instantly still brings up this error as soon as the first view was created. Notice: Undefined offset: 1 in views_block_view() (line 579 of etc..

Am I uninstalling wrong? do I have to clear stuff from the database manually?

I checked the source of the error and it is in views.module file

list($name, $display_id) = explode('-', $delta);

cartagena’s picture

I did...and I've since learned to not change anything! And if I have to delete or change, I work backwards, deleting images from the node then disabling the block/view/panel then deleting the node and maybe even the content type. Then I make sure the image is no longer in the media library. Then I check to make sure it's no longer in the default/files directory. Has taught me to think things through very carefully before I do anything. And think twice before changing or deleting.

HunterT’s picture

Please tell me I don't have to delete any of my sites content because of this. I have several project nodes created that involve pictures and info etc.. Shouldn't this only be a problem that can be fixed with clearing all of the views data and then just re adding every single view carefully.

cartagena’s picture

I'm not sure. I'd certainly try that as well as manually cleaning the block table as in post #10--that helped me. Fortunately I was early enough into the project that it wasn't major for me to start over. Actually, I've started over a couple times but all is well now. Hope you get it working without too much lost time!

HunterT’s picture

Well, So far I kept all of my content. Went to modules and disabled views... then the uninstall tab and uninstalled everything through the site. Then just re enabled views and started added my views again and so far no error. I just have to be careful with renaming machine names this time and I hope that is the only thing that causes it.

cartagena’s picture

Good luck! hope the error stays away!

gilzero’s picture

+1 to #12
Manually delete row from phpmyadmin works.

dawehner’s picture

It would be cool if someone could post a step by step instruction how to reproduce this patch.

If someone give this i promiss to fix this bug asap.

scor’s picture

@dereine: How to reproduce is described in #0.

dawehner’s picture

Assigned: Unassigned » dawehner

Ups. Didn't expected it that someone reported a good issue :) Great

GerdC’s picture

@dereine: I'm sure renaming is is only one way to reproduce the bug, deleting works also.
see #35

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.96 KB

Here is a new version.

This patch does only fix the bug when you produce them. It doesn't magically fix already broken views.
So please please test this issue. It requires your help to fix this issue

GerdC’s picture

I applied the patch and did what I described in #35.
The bug is still there for the deleting case.
You might argue that renaming a block and deleting it is a different thing. Is it your intention to fix the deletion, too?

I dont understand the line
+ $section = $form_state['section'];
I have the impression that you never use the variable $section.

dawehner’s picture

Status: Needs review » Fixed

Commited a fix the original patch used the bid column but it's delta.

bjc5070’s picture

can anyone be really specific as to how to find the table?

I dont know phpmyadmin well, but i know a little.
my steps to try and find the right table....

logged in to phpmyadmin.
chose databases tab
chose my database
from there I dont know where to go.... views table? I dont see anything for blocks or delta.

dawehner’s picture

It's the block table.

sidharth_k’s picture

subscribing

entilza72’s picture

This may or may not be useful to some.

I came to this thread because of the error message, not the description. The description as a cause doesn't apply to me, but the error message does.

I didn't rename a block display to create the issue. Instead, I upgraded from 7.x-1.x-dev to 7.x-3.x-dev. Suddenly the error appeared.

I fixed the issue simply by going into the Blocks config panel in Drupal itself (not mysql) and simply clicking Save. In other words, I had Drupal rewrite the "config" for Blocks. This immediately fixed the issue.

Cheers,
Ent.

karc2009’s picture

Hi,

I also encountered this error, but I don´t really know how to delete the entrys from my database.
I already found them at block-->delta. I can see something like: "2dce955e4c4d5ffd046d2d370bfbe72" as the ID in there, but how can I edit or delete them in phpmyadmin?

Can I do this directly (by menu) in phpmyadmin or do I have to put in a mysql-Command?

!!!!!!!!!!!!!!
Edit: Already found it, the error is gone now.

I would like to describe, how I did it step by step. but i got phpmyadmin in german, so I don´t know the english version and its labels for the menu. I ll try it anyway:

1. !!! Download your Database to have a Copy, if something goes wrong !!!
2. Select block table (displays structure of block table)
3. Select "show" or maybe "display" (don´t know how its called i english phpmyadmin) from the tabs on the top of the structure list (it should be the first Tab).
4. Search in the now displayed page for the strange entries (e.g. 2dce955e4c4d5ffd046d2d370bfbe72) in the row: "delta Unique ID for block within a module." by browsing page by page.
5. Delete them one by one, by clicking on "x" (maybe some entries are doubled, tripled etc., depends on how much themes are installed.
6. Alternatively (if there are a lot of wrong entries ) check the box, before each and click on the "x" at the bottom of the list. Of yourse be careful and look again at the boxes you checked

senortim’s picture

Beautiful! Thanks! Can't tell you how many times I'd deleted and rebuilt blocks, reloaded views, and cleaned my cache....

CodeBru’s picture

After you delete the records with the strange hex names what is the best way to recreate them?

Blooniverse’s picture

@stucz#56: Why recreate them? I didn't. These entries shouldn't exist (stale).

Status: Fixed » Closed (fixed)

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

m4olivei’s picture

Not sure if this is still being worked one, but I ran into this issue today as well. I fixed it as suggested.

It seemed to me that this thread was lacking some facts. I also happened to stumble on an explanation as to why there is a hash name for the delta from merlinofchaos:

http://drupal.org/node/346602#comment-1157029

It could help whoever may be looking to patch this.

temosayin’s picture

The reason this happens is because of the delta limitation of the block module.

See Comment in Views Module:

// block.module has a delta length limit of 32, but our deltas can
// unfortunately be longer because view names can be 32 and display IDs
// can also be 32. So for very long deltas, change to md5 hashes.

puppyman’s picture

Deleting from block table worked!

aurelien1402’s picture

Hi,

This post saved me hours. I followed the guy, his path is very good and quick. I had a sqlite database, it worked too. The site is offline but google cache is our friend!

http://webcache.googleusercontent.com/search?q=cache:00kFCF01GAwJ:objits...

Good luck!

anithegregorian’s picture

Issue tags: +views

The best and easy way to do it is when your creating a new view, notice the machine name that it takes automatically. This is where it all starts.

If you still do not wish to go through heaps of clearing drupal tables and blocks, then try this (but always have a backup). Open up views_view table, find your view/block which needs correction and just rename the name field of that view to a really short and sweet name, and clear your Drupal cache.

Most likely you will loose all your Views Block settings, but now you will have a short more meaningful block ID

jackhutton’s picture

i walked through your method here and was able to clear the error from the page..

arowland’s picture

This was the solution for me. Thank you @scor!

Richard_1618’s picture

Very frustrating but I simply went into myphpadmin and emptied the block table. Reset all the blocks and everything worked perfectly.

Just wish I hadn't deleted all my views and had to now go and re-create everything....

youngelpaso’s picture

Good gravy! Man, this was giving me a huge headache! Huge props to m4olivei for figuring out the source of this issue by going to the proverbial horse's mouth. I was creating a feature and had manually changed the view name, making it longer, and thereby making the delta crazy.

Simplest solution for me was to rename/recreate the view with a much shorter name.

fradipa’s picture

Hi Everybody,

Another very simple way may be:

  1. export the Old View into a text editor
  2. modify the second line: $view->name = 'shorter_name';
  3. import the the New View
  4. delete the Old View

Cheers.