I deleted a media gallery node that was currently employed as a media gallery block, and the block remains with "No content available." in the content box. On all pages where this block appears I also get an error:

"Notice: Trying to get property of non-object in media_gallery_block_view() (line 567 of /home/user/public_html/url.com/sample1/sites/all/modules/media_gallery/media_gallery.module)."

Now I can't delete the remaining block because it does not appear in the blocks admin page.

Anyone know how to fix this?

SR

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DL7BJ’s picture

Exactly the same here.

Tom

Skin’s picture

I deleted a media gallery node that was currently employed as a media gallery block, and the block remains with "No content available." in the content box. On all pages where this block appears I also get an error......Now I can't delete the remaining block because it does not appear in the blocks admin page.

Same problem here, have you any suggestion? Thanks.

Skin’s picture

Version: 7.x-1.0-beta6 » 7.x-1.0-beta7

I deleted a media gallery node that was currently employed as a media gallery block, and the block remains with "No content available." in the content box. On all pages where this block appears I also get an error......Now I can't delete the remaining block because it does not appear in the blocks admin page.

Same problem here, have you any suggestion? Thanks.

skape’s picture

I've got exactly the same problem. Any suggestions how to get rid of that orphaned block?
When I try to edit the block directly through the interface on the page I get this message:

Notice: Trying to get property of non-object in media_gallery_block_configure() (Zeile 631 von /home/.sites/28/site613/web/web/sites/all/modules/media_gallery/media_gallery.module).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (Zeile 7389 von /home/.sites/28/site613/web/web/includes/common.inc).

Thanks for any help!

Moloc’s picture

Status: Active » Needs review
FileSize
1006 bytes
1.13 KB

Here are two patches.
- delete-block fixes the issue.
- remove-abandoned-blocks remove the blocks on next update

bryanhirsch’s picture

Status: Needs review » Reviewed & tested by the community

These patches look good to me.

Tested on my local install. Works as expected.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs work

@Moloc, thanks so much for this patch (and for all the other work you've been doing in the issue queue). I wish more people were able to do that!

This patch doesn't look right to me, though. First, the Block module can be uninstalled so there's no guarantee that a database table called 'block' will exist, and therefore this will result in fatal errors on some sites. (I realize that may be a problem with the existing code too.)

Also, I don't see it as a Media Gallery bug that the block doesn't get removed from the database. Isn't it the Block module's job to rehash blocks (e.g. when the user visits admin/structure/block)? If that isn't happening it's probably a bug in Drupal core... We shouldn't have to go into the {block} table and mess around there in this module.

As an example of what I mean, there are a lot of other modules that have dynamic blocks just like Media Gallery does and therefore can experience a similar problem. I just tested this with Webform and Views, and in both cases, the record in the {block} table remained, even after the webform or view was deleted from the site. So the general problem here is more widespread. (Note that I also tested it with Aggregator, which behaves differently and does try to delete the block from the database, but see #1373360: Fatal error if optional Block module is not enabled and #1378354: Properly remove dependency of aggregator module on block module - that's kind of its own mess.)

Anyway, the reason things don't look bad for Views and Webform is that they are smart enough not to print any content at all when the block doesn't exist. I think we'd be better off doing the same thing here, and I will see if I can come up with a patch.

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
2.02 KB

How about something like this?

As written, the patch would actually allow removal of the media_gallery_update() function entirely if we wanted to... But I thought it was best not to do that yet, both because of performance considerations (if we leave the block there even after people have toggled the "Create a block of most recently added media" checkbox off, that's an unnecessary node being loaded for a block that won't be displayed) and because it might be disconcerting for someone who turned off that checkbox at one point to come back a month later, turn it on, and have the block unexpectedly pop back onto their site in the same place they left it, rather than starting off as a disabled block. So at least for this issue, we probably shouldn't change that behavior.

David_Rothstein’s picture

bryanhirsch’s picture

Status: Needs review » Reviewed & tested by the community

@David_Rothstein Thanks for your insightful response. Good points about block module.

I reviewed patch #8 and tested locally. It look good to me and works as expected in my local install.

Moloc’s picture

I can confirm, that the patch locks good and works well.
Thanks for the detail information and the issue in #9

jessebeach’s picture

Tested and it functions without problem, as expected.

RTBC.

carole’s picture

Subscribe.

shakeeltariq’s picture

Subscribe

noizo’s picture

Thanks,
patch #8 helped a lot.

lsolesen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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