Limiting does not work for newly created nodes

Created on 5 June 2025, 23 days ago

While creating a new node, I recognized that paragraphs, that are configured forbidden, are still available to insert into the node.
I debugged that and saw, that in \Drupal\layout_paragraphs_limit\EventSubscriber\LayoutParagraphsLimitAllowedTypesSubscriber::typeRestrictions line 64 the call to
$entity = $paragraph->getParentEntity();
always returns Null for newly created nodes and therefore the restriction mechanism is not working.

If the node has been already saved, everything works as expected.

I found 2 probably related issues, but if I install the 2 patches from https://www.drupal.org/project/layout_paragraphs/issues/3352822#comment-... 🐛 Paragraph parent entity property is empty when adding new paragraphs Needs review i end up with the error message reported at https://www.drupal.org/project/paragraphs/issues/3255456#comment-16044594 🐛 Cannot access parent entity in hook_entity_create Needs review

Versions installed:
Drupal Core: 10.4.6
Paragraphs: 1.19.0
Layout Paragraphs: 2.1.1
Layout Paragraphs Limit: 1.0.4

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇭Switzerland megadesk3000

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @megadesk3000
  • 🇭🇺Hungary nagy.balint

    I am not sure if the latest version of the module is used, since

    $paragraph = $parent->getEntity(); is at line 80, and not 64.

    Can you check if there is a dblog entry with an error message when this happens?

    Are you using the "Mercury Editor" module or it is only a normal install and the edit page of a node?

    I tried but could not reproduce it on my site.

  • 🇨🇭Switzerland megadesk3000

    Hi nagy.balint

    I rechecked my issue and you are completely right. We were using a custom patch that introduces the issue ( https://www.drupal.org/project/layout_paragraphs_limit/issues/3381902#co... Configure disallowed paragraphs per content type Active ).
    I rechecked it without the patch, and now the reported issue does not exist.

    Thanks for your help! I will close that issue here

Production build 0.71.5 2024