Problem/Motivation
'Delete' on the contextual menu for a custom block deletes the block, not the instance, and then navigating to another page gives the error, "The website has encountered an error. Please try again later".
Perhaps there is a way to fix the error, but I had to reinstall.
To reproduce:
- In the Tools block, click 'Add Custom block'
- Enter title and text, then click 'Save'
- Select Region, then click 'Save Block'
- Navigate to Home
- Find the new custom block
- Hover over block until editing icon appears
- Click icon, see screenshot.
- Caution, will break your site. Click 'delete'. Navigate to another page. The error msg displays.
Proposed resolution
Remove 'Delete' from the contextual menu.
Remaining tasks
- Discuss.
- Create initial patch to remove 'delete' from the contextual links.
User interface changes
See Proposed resolution
API changes
None
Related Issues
#574018: Add "Delete" button to "Configure block" screen
#1956496: Custom block contextual links should differentiate between editing/deleting the block instance and the custom block entity
#1956504: Add block instance delete to block contextual links
#1997262: Convert custom_block_delete_form to new form interface
Comment | File | Size | Author |
---|---|---|---|
#23 | delete-block-1994146.23.interdiff.txt | 2.58 KB | larowlan |
#23 | delete-block-1994146.23.patch | 5.31 KB | larowlan |
#22 | delete-block-1994146.22.interdiff.txt | 2.59 KB | larowlan |
#18 | 1994146-delete-block-18.patch | 4.1 KB | kim.pepper |
#18 | 1994146-interdiff.txt | 1.48 KB | kim.pepper |
Comments
Comment #1
larowlanWe need to remove instances too.
Comment #2
larowlanComment #3
bleen CreditAttribution: bleen commentedIt seems to me that there are a few options:
They are all valid solutions... personally I would expect "3" but who knows...
Comment #4
klonosWhatever it may be (I expect 3 too), it needs to be something less vague than simply "delete". So, either "delete block" (+ a warning in a modal to state that ALL instances are going to be deleted) or "delete this block instance" (which is pretty much self-explanatory).
In fact I believe we can make a better distinction of the two by perhaps using "delete" for the more destructive block deletion and "remove" (that implies it can be added back again) for the instance. Although I cannot know how that would translate to other languages (in some languages both words might be the same or have less distinction between them).
Comment #5
Gábor HojtsyI don't see why its a problem that you can delete the block directly from there. You can also do the same on a node. I think its a minority case, that you'd use the same block elsewhere as well, the delete page actually can inform you about that if we want to. That an error is displayed then is a different question, not related to the Delete operation being there.
I'm wondering how this is a major.
Comment #6
larowlanIf you create and place a block and then delete it using the delete link, it doesn't remove the block instance config entity before deleting and your site is then hosed.
I think that warrants major but happy for it to be knocked down to normal.
Comment #7
Gábor HojtsyOk, I agree that is at least major (I think critical).
But the bug then is not that Delete is a contextual link, but that deleting a custom block will not result in all placements removed as well, right? If you go to edit the block and then go to Delete on the edit screen, it will do the same, no? I tried (DID NOT use the contextual delete link), and first I got this "ok" message:
But then after trying to submit another block, I indeed got into this for all my site pages with no way to get out of this:
If it is so easy to WSOD a site as to create a custom block, place it and then remove the content entity, then this is a critical.
Comment #8
larowlanIn which case this just became my top priority :)
Will try and look at it over the weekend
Comment #9
larowlanFail and pass
Comment #10
Gábor HojtsyLooks generally pretty good! Also quick work! :)
Make this a full sentence IMHO. Add a period.
Should assert format_plural(1, '...', '...'), this may look odd, but it would find the exact string translation that way.
Should assert this with t() as well.
Comment #11
larowlanFixes issues at #10
Comment #12
andypostNice fix with test, +1 rtbc
Comment #13
alexpottTo prevent a PHP warning in the submit I think this should be... so that we always have
$form_state['values']['instances']
Comment #14
alexpottComment #15
kim.pepperChanges in #13
Comment #16
alexpottOops... If the following works then this should be...
If we avoid conditionals in form builders alters become much simpler...
Comment #17
kim.pepperChanges in #16 plus additional test for not showing a message if there are no instances.
Comment #18
kim.pepperDiscussed the new test with IRC with @alexpott and agreed to move it into testBlockDelete() and make it more clear that we are testing the confirm form message.
Comment #19
andypostI think we need this element in form array. It was broken. So filed a better to have count and plurals are separate.
anyway we should decide on a language-aware renderable element be a source for markup
Language tested but is there injection?
Also - do this a unit test for form and UI of delete as a part of testBlockDelete() makes sense from follow-up
Comment #20
kim.pepperDiscussed with @alexpott and @andypost in IRC last night, and the suggestion was to move the deleting of instances behind
CustomBlock::delete()
. This would mean displaying the additional message about how many instances are going to be removed, more complex, as we'd need to do a query first. Something likeCustomBlock::countInstances()
?Comment #21
larowlanHow about ::getInstances, that would be more useful. But +1 for making it part of the delete method, decoupling from forms is definitely better design.
Comment #22
larowlanSomething like so?
Comment #23
larowlan#22 plus new test for getInstances method, plus remove unneeded 'instances' form key.
Comment #24
andypostSo about #d8mi we have separate issue now and everything addressed about the scope. RTBC
also the ability to implement unit test would be found in follow-up #2015543: Decide on a language-aware renderable element in Twig templates
Awesome!
Makes sense here too!
Comment #25
alexpottYay!
Committed a74a17a and pushed to 8.x. Thanks!
Comment #26.0
(not verified) CreditAttribution: commentedAdded related issue.