Process:

1) Create custom block type.

2) Create a new block, of that new block type just created. [Give the block a title that contains a '.'] Example title: "This.is custom"

3) Go to block layout, and place that new block, in a region.

4) Place that same block in an additional region.. The error will occur at this point.

Drupal Will Log this error:

Drupal\Core\Entity\EntityStorageException: 'block' entity with ID 'moregreatpeople...' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 430 of /Users/micahjoyner/www/cmm.dev/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

So, it appears that it can't seem to create a proper unique ID, for any additionally place block, if the title contains a period in it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cheeky-micah created an issue. See original summary.

larowlan’s picture

Status: Needs work » Active
cilefen’s picture

Issue tags: -blocks, -Custom Block Type, -Multiple Regions, -block regions
markconroy’s picture

Hi guys,

Just confirming this bug. My steps to reproduce:

- A block named 1.3.1 was placed in a region.
- Set that block to 'none' (so it's placed in 'Disabled').
- Try to place that block in a region using the 'Place block' widget on the /admin/structure/blocks/ page at the desired region
- Error message: 'The website has encountered an unexpected error'.
- Log message: 'Drupal\Core\Entity\EntityStorageException: 'block' entity with ID '1.3.1abovecontent' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 430 of /Users/markconroy/htdocs/adesignforlife/envato/adfl-alpha/docrooot/core/lib/Drupal/Core/Entity/EntityStorageBase.php).'

Note: If I got to the 'Disabled' section on the blocks page and choose the region I want the block to appear, it works fine from there. But I can't enable any other blocks (more than once) that also have a full stop/period in their names.

larowlan’s picture

Version: 8.0.5 » 8.1.x-dev
Issue tags: +Needs tests
larowlan’s picture

The issue here is that \Drupal\block\BlockForm::getUniqueMachineName treats the . as a config delimiter.

Simple fix is to disallow the . from block IDs. That makes sense anyway as it would mess with the config system, where the . has significance.

Failing test and fix.

The last submitted patch, 6: 2685917-block-period-exception.fail_.patch, failed testing.

tim.plunkett’s picture

  1. +++ b/core/modules/block/src/BlockForm.php
    --- /dev/null
    +++ b/core/modules/block/tests/src/Kernel/BlockMachineNameTest.php
    
    +++ b/core/modules/block/tests/src/Kernel/BlockMachineNameTest.php
    @@ -0,0 +1,87 @@
    +namespace Drupal\Tests\block\Kernel;
    ...
    + * @group block
    ...
    +    $this->installEntitySchema('block_content');
    

    Shouldn't this be block_content, not block?

  2. +++ b/core/modules/block/tests/src/Kernel/BlockMachineNameTest.php
    @@ -0,0 +1,87 @@
    +  public function testMachineNamesShouldNotCollideIfBlockTitlesContainPeriod() {
    

    descriptiveTestMethodNamesAreTheBest

  3. +++ b/core/modules/block/tests/src/Kernel/BlockMachineNameTest.php
    @@ -0,0 +1,87 @@
    +    $id = $this->container->get('transliteration')->transliterate($block_content->label(), LanguageInterface::LANGCODE_DEFAULT, '_');
    +    $id = Unicode::strtolower($id);
    +    $id = preg_replace('@[^a-z0-9_.]+@', '', $id);
    

    Why not just use a string with the known result of this?

Fix looks good!

larowlan’s picture

1) no, the bug is in BlockForm and BlockBase
2) :)
3) BlockBase::getMachineNameSuggestion is protected, I guess I could use reflection and call it instead of this dance, I have the plugin from $block->getPlugin() - thoughts?

tim.plunkett’s picture

1) Duh, of course. Thanks :)

3) I'm not averse to reflection in tests, so that wfm. I think it will be clearer.

larowlan’s picture

Moved to reflection approach.

Also added user entity for 8.2/8.3 where we have a revision user for block content.

The last submitted patch, 11: 2685917-block-period-exception.test-only.patch, failed testing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

I think that is much clearer. Thanks!

  • catch committed 803a98a on 8.3.x
    Issue #2685917 by larowlan, tim.plunkett, cheeky-micah: Placing the same...
catch’s picture

Fixed some unused use statements on commit to 8.3.x

Leaving RTBC against 8.2.x, nice find.

xjm’s picture

I get nervous when I see support for something removed without an explanation of why it was there to begin with. I remember in the original BAP conversion that there was a whole lot of work specifically around supporting that dot operator. #2043527: Theme name is included in block machine name but should be stored as a key instead removed the pseudo-namespacing-by-theme from block instances and therefore the need for it.

However, what happens if someone has an existing block instance with the dot in its macine name on their site following this patch?

xjm’s picture

Version: 8.3.x-dev » 8.2.x-dev

Oops, did not mean to change the branch.

  • catch committed f55f7e0 on 8.3.x
    Revert "Issue #2685917 by larowlan, tim.plunkett, cheeky-micah: Placing...
catch’s picture

Status: Reviewed & tested by the community » Needs review

That's a good question, we need an upgrade path for existing blocks at a minimum. Reverted for now.

Londova’s picture

+

Dinesh18’s picture

I have checked and able to replicate the issue. I would suggest, if we can add a validation so that it would not allow period to add in Block Title. If you can check any of the contributed blocks placed doesn't have any period.

  • catch committed 803a98a on 8.4.x
    Issue #2685917 by larowlan, tim.plunkett, cheeky-micah: Placing the same...
  • catch committed f55f7e0 on 8.4.x
    Revert "Issue #2685917 by larowlan, tim.plunkett, cheeky-micah: Placing...

  • catch committed 803a98a on 8.4.x
    Issue #2685917 by larowlan, tim.plunkett, cheeky-micah: Placing the same...
  • catch committed f55f7e0 on 8.4.x
    Revert "Issue #2685917 by larowlan, tim.plunkett, cheeky-micah: Placing...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Munavijayalakshmi’s picture

Tom M Fallon’s picture

FileSize
65.98 KB

Hello

Just tested #26 2685917-block-period-exception.26.patch

1) Installed Drupal Core 8.3.x
2) Applied Patch successfully
3) Created a block called "This.is custom" and added to "Breadcrumb" region
4) Created a second block called "This.is custom2" and added to "Content" Region
5) Clicked Save
6) This saves successfully with no errors shown and no errors shown in logs.

Screen shot of success page
Success After Block Page Save

Tom M Fallon’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work

There's still no update path as per #17 and #20. As per #17 I think we need to support dots in custom block titles and work out why this is happening and fix in a different way.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

subhojit777’s picture

I was also seeing this error in Drupal 8.3.2. There were two breadcrumb blocks created, but they were placed in different regions. One of the block was disabled. And while I was installing a module I was getting

Drupal\Core\Entity\EntityStorageException: 'block' entity with ID 'custom_admin_theme_breadcrumb...' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 430 of /Users/micahjoyner/www/cmm.dev/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

After I deleted the disabled block, the theme installed without any error.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.5.x-dev » 10.1.x-dev
Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative

I tested this on Drupal 10.1.x, standard install and was not able to reproduce the problem.

The patch here is fixing this by changing code in /core/lib/Drupal/Core/Block/BlockBase.php. That code was removed in #3091309: Broken context-aware block plugins throw an unexpected exception. I suspect this was fixed by that but can't be sure.

Therefore, closing as outdated. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!