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:

  1. Go to this path in your local installation: /admin/structure/block/list/block_plugin_ui%3Abartik/add
  2. Click the 'Add custom block' button
  3. Your site should WSOD

Screenshot of the custom block list. The path is indicated and the Add custom block button is indicated

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

tim.plunkett’s picture

Shorter steps to reproduce:

Go to http://example.com/block/add

tim.plunkett’s picture

Status: Active » Needs review
Issue tags: +Needs tests
larowlan’s picture

I will tackle this next week at the latest

Status: Needs review » Needs work

The last submitted patch, add-custom-block-wsod.patch, failed testing.

naxoc’s picture

#2027177: "Add custom block" broken is related to this and has a patch going.

tim.plunkett’s picture

Status: Needs work » Needs review

add-custom-block-wsod.patch queued for re-testing.

pplantinga’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work

Unfortunately, we still need to add a regression test before this can be committed.

kartagis’s picture

I'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

pplantinga’s picture

Are 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.

naxoc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.66 KB

Here 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.

kartagis’s picture

I applied the patch in the original issue body, and everything looks good.

juampynr’s picture

Duplicate 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.

pplantinga’s picture

StatusFileSize
new2.93 KB

Updated documentation on 'add' function.

juampynr’s picture

Status: Needs review » Reviewed & tested by the community

This is ready to go.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 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.

d8test --class 'Drupal\custom_block\Tests\CustomBlockCreationTest'

Drupal test run
---------------

Tests to be run:
 - Custom Block creation (Drupal\custom_block\Tests\CustomBlockCreationTest)

Test run started:
 Thursday, June 27, 2013 - 20:49

Test summary
------------

Custom Block creation 74 passes, 6 fails, and 3 exceptions

Test run duration: 53 sec
yesct’s picture

Issue tags: -Needs tests

had tests. removing needs tag. :)

Status: Fixed » Closed (fixed)

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