Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#8 | media-gallery-no-block-1273544-8.patch | 2.02 KB | David_Rothstein |
#5 | delete-block-1273544-5.patch | 1.13 KB | Moloc |
#5 | remove-abandoned-blocks-1273544-5.patch | 1006 bytes | Moloc |
Comments
Comment #1
DL7BJ CreditAttribution: DL7BJ commentedExactly the same here.
Tom
Comment #2
SkinSame problem here, have you any suggestion? Thanks.
Comment #3
SkinSame problem here, have you any suggestion? Thanks.
Comment #4
skape CreditAttribution: skape commentedI'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!
Comment #5
Moloc CreditAttribution: Moloc commentedHere are two patches.
- delete-block fixes the issue.
- remove-abandoned-blocks remove the blocks on next update
Comment #6
bryanhirsch CreditAttribution: bryanhirsch commentedThese patches look good to me.
Tested on my local install. Works as expected.
Comment #7
David_Rothstein CreditAttribution: David_Rothstein commented@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.
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedHow 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.
Comment #9
David_Rothstein CreditAttribution: David_Rothstein commentedHere's the Drupal core bug, by the way:
#1227966: Dynamically-defined blocks are never removed from the site, even when they disappear from hook_block_info()
Comment #10
bryanhirsch CreditAttribution: bryanhirsch commented@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.
Comment #11
Moloc CreditAttribution: Moloc commentedI can confirm, that the patch locks good and works well.
Thanks for the detail information and the issue in #9
Comment #12
jessebeach CreditAttribution: jessebeach commentedTested and it functions without problem, as expected.
RTBC.
Comment #13
carole CreditAttribution: carole commentedSubscribe.
Comment #14
shakeeltariq CreditAttribution: shakeeltariq commentedSubscribe
Comment #15
noizo CreditAttribution: noizo commentedThanks,
patch #8 helped a lot.
Comment #16
lsolesen CreditAttribution: lsolesen commented