Problem/Motivation
From a standard installation with only one custom block type (the default), Adding a custom block instance results in a fatal error.
Steps to reproduce:
- Go to this path in your local installation: /admin/structure/block/list/block_plugin_ui%3Abartik/add
- Click the 'Add custom block' button
- Your site should WSOD

Proposed resolution
timplunkett provided a gist for this problem in chat. It's attached as a patch. jessebeach confirmed that that patch resolves the WSOD issue.
timplunkett mentions that current tests for this functionality pass most likely because the tests include a custom block type in addition to the default custom block type. The code path with only one custom block type probably does not have test coverage.
Remaining tasks
Add a test for this case.
Comments
Comment #1
tim.plunkettShorter steps to reproduce:
Go to http://example.com/block/add
Comment #2
tim.plunkettComment #3
larowlanI will tackle this next week at the latest
Comment #5
naxoc commented#2027177: "Add custom block" broken is related to this and has a patch going.
Comment #6
tim.plunkettadd-custom-block-wsod.patch queued for re-testing.
Comment #7
pplantinga commentedLooks good to me!
Comment #8
tim.plunkettUnfortunately, we still need to add a regression test before this can be committed.
Comment #9
kartagisI've just git pull'd and am getting this error: PHP Fatal error: Call to a member function get() on a non-object in /var/www/drupal-8/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php on line 105
Comment #10
pplantinga commentedAre you sure you applied the patch correctly? That's the error this patch solves. I just applied the patch to the latest codebase and it worked fine for me.
Comment #11
naxoc commentedHere is a test that tests going to add/block and not passing a block type as an argument in the url.
The test function does the same as the
testCustomBlockCreation()function (creates a custom block of the type 'basic'), but this tests that the UI also works with no args passed.Comment #12
kartagisI applied the patch in the original issue body, and everything looks good.
Comment #13
juampynr commentedDuplicate of #2028701: Adding a custom block crashes, where I implemented a simpler version of the test.
There is no need to submit the form, at the moment simply accessing block/add crashes in core so a simpler GET request can test this bug. It depends how deep we want to test this.
Let's see the results from the testbot.
Comment #14
pplantinga commentedUpdated documentation on 'add' function.
Comment #15
juampynr commentedThis is ready to go.
Comment #16
alexpottCommitted a3fea49 and pushed to 8.x. Thanks!
I've manually run the test only... it fantastic if you add a test only patch when fixing a bug and including a test.
Comment #17
yesct commentedhad tests. removing needs tag. :)