Problem/Motivation

Currently the Inline Blocks functionality makes assumptions about how override sections are stored so it will only work with core's provide section storages.

Proposed resolution

Make inline blocks not assumption section storage internals

Remaining tasks

User interface changes

None

API changes

Hopefully we can do this with the existing API

Data model changes

None

Release notes snippet

CommentFileSizeAuthor
#80 3026434-internals-80-interdiff.txt2.08 KBtim.plunkett
#80 3026434-internals-80.patch31.06 KBtim.plunkett
#70 3026434-internals-70.patch30.55 KBtedbow
#70 interdiff-66-70.txt3.76 KBtedbow
#66 3026434-66.patch30.17 KBtedbow
#66 interdiff-64-66.txt1.09 KBtedbow
#64 3026434-internals-63.patch29.08 KBtedbow
#63 3026434-internals-63.txt29.08 KBtedbow
#63 interdiff-62-63.txt15.61 KBtedbow
#62 3026434-internals-62-interdiff.txt5.37 KBtim.plunkett
#62 3026434-internals-62.patch18.51 KBtim.plunkett
#59 3026434-59.patch15.06 KBtedbow
#59 interdiff-57-59.txt925 bytestedbow
#57 3026434-57.patch14.99 KBtedbow
#57 interdiff-54-56.txt4.61 KBtedbow
#54 3026434-54.patch14.99 KBtedbow
#54 interdiff-53-54.txt1.23 KBtedbow
#52 3026434-52.patch14.99 KBtedbow
#52 interdiff-51-52.txt1002 bytestedbow
#51 3026434-51.patch14.74 KBtedbow
#51 interdiff-45-51.txt948 bytestedbow
#45 3026434-45.patch14.76 KBtedbow
#45 interdiff-44-45.txt906 bytestedbow
#44 3026434-43.patch14.77 KBtedbow
#44 interdiff-41-43.txt1.13 KBtedbow
#41 3026434-41.patch14.76 KBtedbow
#41 interdiff-35-41.txt2.65 KBtedbow
#35 interdiff-27-35.txt3.52 KBtedbow
#35 3026434-35.patch14.21 KBtedbow
#32 3026434-32.patch14.36 KBtedbow
#32 interdiff-27-32.txt939 bytestedbow
#27 3026434-27.patch14.36 KBtedbow
#27 interdiff-24-27.txt2.64 KBtedbow
#24 interdiff-22-24.txt3.38 KBtedbow
#24 3026434-24.patch14.23 KBtedbow
#22 3026434-22.patch11.49 KBtedbow
#22 interdiff-20-22.txt1.58 KBtedbow
#20 3026434-20-refactor-inline-blocks.patch11.08 KBtedbow
#20 interdiff-18-20.txt760 bytestedbow
#18 3026434-18-refactor-inline-blocks.patch11.07 KBtedbow
#18 interdiff-16-18.txt2.27 KBtedbow
#16 interdiff-11-15.txt1.25 KBtedbow
#16 3026434-15-refactor-inline-blocks.patch11.1 KBtedbow
#13 3026434-13-refactor-inline-blocks.patch11.16 KBtedbow
#13 interdiff-11-13.txt755 bytestedbow
#11 3026434-11-refactor-inline-blocks.patch10.42 KBtedbow
#11 interdiff-9-11.txt5.36 KBtedbow
#9 3026434-9-refactor-inline-blocks.patch11.72 KBtedbow
#9 interdiff-6-9.txt7.83 KBtedbow
#6 3026434-6.patch8.98 KBtedbow
#6 interdiff-4-6.patch1016 bytestedbow
#4 3026434-4-refactor-inline-blocks.patch8.98 KBtedbow
#4 interdiff-2-4.txt1.82 KBtedbow
#2 3026434-refactor-inline-blocks.patch8.86 KBtedbow

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
StatusFileSize
new8.86 KB

First try at it

Status: Needs review » Needs work

The last submitted patch, 2: 3026434-refactor-inline-blocks.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new1.82 KB
new8.98 KB
+++ b/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php
@@ -127,7 +127,7 @@ protected function getInlineBlockDependency(BlockContentInterface $block_content
-    if ($this->isLayoutCompatibleEntity($layout_entity)) {
+    if ($this->getSectionStorageForEntity($layout_entity) !== NULL) {

I made this change so to agnostic about storage. So if a storage says it is applicable then it is compatible with Layout Builder.

But I was passing the entity's display as 'display' context without checking to see if it was a LayoutBuilderEntityViewDisplay instance and this caused a fatal error in \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::isApplicable() not sure if we need extra checking inside that function because another storage type could also use the 'display' context but with different type of entity.

but that would be a different issue

Status: Needs review » Needs work

The last submitted patch, 4: 3026434-4-refactor-inline-blocks.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new1016 bytes
new8.98 KB
  1. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -94,16 +80,35 @@ protected function getInlineBlockComponents(array $sections) {
    -   * @return bool
    ...
    +        $display = EntityContext::fromEntity(EntityViewDisplay::collectRenderDisplay($entity, $view_mode));
    +        if ($display instanceof LayoutBuilderEntityViewDisplay) {
    

    I didn't mean to already call EntityContext::fromEntity() before the instanceof test.

  2. I see this patch only does #2986403: Create an easy way to get layout sections for an entity.

The last submitted patch, 6: interdiff-4-6.patch, failed testing. View results

plach’s picture

Priority: Normal » Major

This blocks a major so let's make it major as well :)

tedbow’s picture

Title: Ensure that Layout Builder Inline Blocks is section storage agnostic » Ensure that Layout Builder Inline Blocks doesn't assume section storage internals
StatusFileSize
new7.83 KB
new11.72 KB

Changing the title slightly because the inline block logic is not totally storage agnostic.

We want to preserve the existing logic that when a new override is created from the defaults that we duplicate the inline blocks.
You can find the reasons #2957425-72: Allow the inline creation of non-reusable Custom Blocks in the layout builder(and in other comments in that issue)

Updating some comments and using dependency injection to get section storage manager. I also removed a unused var from the constructor in \Drupal\layout_builder\InlineBlockEntityOperations. This an internal class, not because it is experimental but because it should never be used outside of the module.

tim.plunkett’s picture

Status: Needs review » Needs work
Issue tags: +Blocks-Layouts
  1. +++ b/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php
    @@ -127,7 +131,7 @@ protected function getInlineBlockDependency(BlockContentInterface $block_content
    -    if ($this->isLayoutCompatibleEntity($layout_entity)) {
    +    if ($this->getSectionStorageForEntity($layout_entity) !== NULL) {
    
    +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -144,20 +150,16 @@ public function handleEntityDelete(EntityInterface $entity) {
    -    if (!$this->isLayoutCompatibleEntity($entity)) {
    +    if ($this->getSectionStorageForEntity($entity) === NULL) {
    
    +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -16,17 +20,11 @@
    -  protected function isLayoutCompatibleEntity(EntityInterface $entity) {
    

    Can we keep this helper method around and change it to make this exact comparison?

  2. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -128,13 +128,19 @@ protected function getRemovedBlockIds(EntityInterface $entity) {
    +   * We cannot call ::getSectionStorageForEntity() for the deleted entity
    +   * because validating the contexts would throw an exception trying to load the
    +   * deleted entity. Therefore we most attempt to remove the layout usage
    +   * tracking for all deleted entities.
    ...
    +   * @see \Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator::validate
    

    Instead of this @see, can this be an @todo linking to #3008943: Clean up todo in InlineBlockEntityOperations::handleEntityDelete()?

  3. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -128,13 +128,19 @@ protected function getRemovedBlockIds(EntityInterface $entity) {
    +   * @see \Drupal\layout_builder\LayoutEntityHelperTrait::getSectionStorageForEntity
    

    Not sure about this @see, but if you keep it, add the () to the end please

  4. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -264,4 +266,27 @@ protected function saveInlineBlockComponent(EntityInterface $entity, SectionComp
    +    if ($entity instanceof FieldableEntityInterface) {
    

    In theory I understand this check, but none of the code after it really cares if it is fieldable or not...

  5. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -264,4 +266,27 @@ protected function saveInlineBlockComponent(EntityInterface $entity, SectionComp
    +        if ($original_section_storage instanceof DefaultsSectionStorage) {
    

    Let's use the interface here, not the class

  6. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -94,16 +87,33 @@ protected function getInlineBlockComponents(array $sections) {
    +    $contexts = [
    +      'entity' => EntityContext::fromEntity($entity),
    +    ];
    ...
    +      $contexts['entity'] = EntityContext::fromEntity($entity);
    

    Added twice

  7. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -94,16 +87,33 @@ protected function getInlineBlockComponents(array $sections) {
    +    $view_mode = 'full';
    

    This should have an @todo to #3008924: Callers of LayoutEntityHelperTrait::getEntitySections() do not account for the view mode

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new5.36 KB
new10.42 KB
  1. fixed
  2. fixed
  3. removed @see
  4. now checking it $section_storage instanceof OverridesSectionStorageInterface because that is what we really care about.
  5. fixed
  6. whoops! fixed
  7. fixed

The last submitted patch, 9: 3026434-9-refactor-inline-blocks.patch, failed testing. View results

tedbow’s picture

StatusFileSize
new755 bytes
new11.16 KB
+++ b/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php
@@ -64,11 +65,14 @@ class SetInlineBlockDependency implements EventSubscriberInterface {
-  public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsage $usage) {
+  public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsage $usage, SectionStorageManagerInterface $section_storage_manager) {

Tests failed because the constructor for this class was updated but the service definition didn't add the argument so it wasn't loaded.

The service is declared dynamically in \Drupal\layout_builder\LayoutBuilderServiceProvider::register

fixed.

The last submitted patch, 11: 3026434-11-refactor-inline-blocks.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 13: 3026434-13-refactor-inline-blocks.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new11.1 KB
new1.25 KB

Canceled test on #13 to fix standards in #15

Diff from #11

tim.plunkett’s picture

Thanks for the changes!

A couple nits and one question

  1. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -132,9 +130,9 @@ protected function getRemovedBlockIds(EntityInterface $entity) {
    +    // @todo In https://www.drupal.org/node/3008943 call
    +    // \Drupal\layout_builder\LayoutEntityHelperTrait::isLayoutCompatibleEntity()
    
    +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -94,16 +100,32 @@ protected function getInlineBlockComponents(array $sections) {
    +    // @todo Take into account other view modes in
    +    // https://www.drupal.org/node/3008924
    

    Nit: second line should be indented two spaces and end with a trailing space.

  2. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -264,4 +258,28 @@ protected function saveInlineBlockComponent(EntityInterface $entity, SectionComp
    +    if ($section_storage instanceof OverridesSectionStorageInterface) {
    +      if (!$entity->isNew() && isset($entity->original)) {
    

    Nit: could be combined into one to cut down on nesting

  3. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -94,16 +100,32 @@ protected function getInlineBlockComponents(array $sections) {
    -  protected function isEntityUsingFieldOverride(EntityInterface $entity) {
    -    return $entity instanceof FieldableEntityInterface && $entity->hasField(OverridesSectionStorage::FIELD_NAME);
    

    Do we need to provide this method still? If so, could be an instanceof check like the one in entityHasNewOverride()

tedbow’s picture

StatusFileSize
new2.27 KB
new11.07 KB
  1. fixed(confirmed with @tim.plunkett he meant "trailing period" not "space"
  2. fixed
  3. I don't think we need this anymore because we don't need and the trait is marked internal(and it doesn't give the caveat about @internal because of the module being experimental).
    also it gives the impression to a caller that they can rely on how the layout override is stored which I don't think we should imply.

    If so, could be an instanceof check like the one in entityHasNewOverride()

    This actually won't always give the same result as the current method.
    the existing
    $entity instanceof FieldableEntityInterface && $entity->hasField(OverridesSectionStorage::FIELD_NAME);
    won't always be the same as
    $this->getSectionStorageForEntity($entity) instanceof OverridesSectionStorageInterface
    Because they may have the field still the storage could be DefaultsSectionStorageInterface if it has no sections.

tim.plunkett’s picture

+++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
@@ -132,9 +130,9 @@ protected function getRemovedBlockIds(EntityInterface $entity) {
+    // @todo In https://www.drupal.org/node/3008943 call
+    // \Drupal\layout_builder\LayoutEntityHelperTrait::isLayoutCompatibleEntity()

Missed one of the @todos from #17.1 to fix

#18.3, good point.

Does this mean #2986403: Create an easy way to get layout sections for an entity. should be closed as a duplicate?

tedbow’s picture

StatusFileSize
new760 bytes
new11.08 KB

Fixed the @todo

I think we can close #2986403: Create an easy way to get layout sections for an entity.
Unless the intention of that was provide help to custom or contrib code. But since that issue was not removing the @internal I think it is covered by the changes here.

The last submitted patch, 18: 3026434-18-refactor-inline-blocks.patch, failed testing. View results

tedbow’s picture

StatusFileSize
new1.58 KB
new11.49 KB

I chatted with @tim.plunkett again about #17 3, isEntityUsingFieldOverride(). While we are not using it is conceivable that custom code could be calling it even though it is internal.

Adding it back as deprecated.

kristen pol’s picture

Thanks for the update. Confirmed that isEntityUsingFieldOverride was added back in #22 which matches the interdiff. Is there any way to manually test this?

tedbow’s picture

StatusFileSize
new14.23 KB
new3.38 KB

@Kristen Pol no this can't be tested because it the methods is not actually used anywhere. We just have to keep around because contrib might be calling it

Added a test for the method and the deprecation.

tim.plunkett’s picture

Issue tags: +Needs change record

Great! Thanks for adding the deprecation and test.
One additional thing: deprecations are supposed to have CRs associated with them in the trigger_error message. I know this was only recently added but it was in 8.6.0 and it's on a trait.

tedbow’s picture

Issue tags: -Needs change record

Added the change record https://www.drupal.org/node/3030609

tedbow’s picture

StatusFileSize
new2.64 KB
new14.36 KB

Added the change record to the deprecation

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

plach’s picture

Patch looks good to me, just a few questions:

  1. +++ b/core/modules/layout_builder/src/EventSubscriber/SetInlineBlockDependency.php
    @@ -64,11 +65,14 @@ class SetInlineBlockDependency implements EventSubscriberInterface {
    -  public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsage $usage) {
    +  public function __construct(EntityTypeManagerInterface $entity_type_manager, Connection $database, InlineBlockUsage $usage, SectionStorageManagerInterface $section_storage_manager) {
         $this->entityTypeManager = $entity_type_manager;
         $this->database = $database;
    

    Shouldn't we remove the $database connection property and the related constructor param, while we are at this?

  2. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -47,13 +47,14 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
    +  public function __construct(EntityTypeManagerInterface $entityTypeManager, InlineBlockUsage $usage, SectionStorageManagerInterface $section_storage_manager) {
    

    Was the $database param unused?

  3. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -132,9 +130,9 @@ protected function getRemovedBlockIds(EntityInterface $entity) {
    +    // @todo In https://www.drupal.org/node/3008943 call
    +    //   \Drupal\layout_builder\LayoutEntityHelperTrait::isLayoutCompatibleEntity().
    +    $this->usage->removeByLayoutEntity($entity);
    

    Why are we doing this here?

  4. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -264,4 +258,26 @@ protected function saveInlineBlockComponent(EntityInterface $entity, SectionComp
    +  protected function entityHasNewOverride(EntityInterface $entity)
    

    Would it make sense to move this into LayoutEntityHelperTrait?

tedbow’s picture

  1. I would like to remove but seems out of scope. $database seems to be unused in SetInlineBlockDependency
  2. I am not sure how the question relates to InlineBlockEntityOperations. But in SetInlineBlockDependency yes
  3. We are removing the usage tracking for the inline block when the parent is delete. We do this by removing the entity_type_id and entity_id from the usage row. But we don't actually delete these until cron via \Drupal\layout_builder\InlineBlockEntityOperations::removeUnused().

    We wait till cron because an entity that has hundreds of revisions could have multiple unique inline blocks in each revision meaning thousands of inline blocks. So if deleting when the parent is deleted could run into a timeout.

    Also because custom blocks also can have layouts and layout overrides and hence even though own inline block the deleting inline blocks when say a node is delete could cascade down many levels.

  4. We could move this to LayoutEntityHelperTrait because I don't want us to get into a situation like we are now with \Drupal\layout_builder\LayoutEntityHelperTrait::isEntityUsingFieldOverride() where we don't actually need it but we can't delete because of BC(even though since it is marked internal it seems like we should be able to.)

    In fact looking at this again I would prefer to make entityHasNewOverride private. If/when we need it outside of this class in the module we could move it to the trait.

plach’s picture

Ok, thanks

tedbow’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new939 bytes
new14.36 KB

re #30.4 making \Drupal\layout_builder\InlineBlockEntityOperations::entityHasNewOverride() private this is internal logic that we should be to change later.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Oh good point, let's not burn ourselves again

xjm’s picture

Status: Reviewed & tested by the community » Needs work

So:

We should preferably use private for things that, architecturally, should be private, not to avoid providing BC. Increasing the visibility of something later is a disruptive change because it can cause method name collisions. So it's not a total freebie in terms of BC/disruption. (I discussed this with @plach and he was hesitant for policy reasons as well, i.e. our official core policy is still "we never use private, only protected" and we definitely don't have any sort of policy for using private as a substitution for BC or deprecation.)

Furthermore, regardless of that, we should have an @todo linking an issue for what needs to be changed later if we think it needs to be changed later.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new14.21 KB
new3.52 KB

In #32.4 I was giving one reason for not moving this to the LayoutEntityHelperTrait. This was probably colored by the fact that I just dealt writing the depreciation code for the other method on the class.

There are other reasons why this is internal logic to the class and why other classes should not use this as an indicator of if an override is "new".

For this classes logic we want to:

  1. Duplicate the inline blocks if we have just created an override from a default.
  2. Not remove inline blocks if the override was just create from a defaut.

So our logic really cares if $entity->original(if available) use the default storage. Since Layout Builder is extensible system where modules could swap out parts I don't think we can always say this logic will mean it is "new override". That is another reason I didn't want to move it to the trait. I think it would have been confusing as a general helper method and the caller might have assumptions we are not thinking of.

So maybe the method is badly named. I have renamed the method originalEntityUsesDefaultStorage(). Since this a new method in this issue I think it is scope. I believe this is more clear as to what is actually being tested.

As to @plach's original question in #29.4

Would it make sense to move this into LayoutEntityHelperTrait?

I think moving the newly renamed function to the trait is fine because it very clear what is tested and we are not guarenting this a "new override" to the caller just about the storage off the original.

So here is patch that renames it, moves to the trait and makes it protected again. interdiff from 27 before it was made private.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Oh great, that makes much more sense, and no need for a follow-up now. +1 on the new name too!

xjm’s picture

This issue has two CRs that look to be about the same thing; which is preferred?

https://www.drupal.org/node/3030609
https://www.drupal.org/node/3028211

xjm’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
@@ -47,13 +47,14 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
-   * @param \Drupal\Core\Database\Connection $database
-   *   The database connection.
+   * @param \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager
+   *   The section storage manager.
    */
-  public function __construct(EntityTypeManagerInterface $entityTypeManager, InlineBlockUsage $usage, Connection $database) {
+  public function __construct(EntityTypeManagerInterface $entityTypeManager, InlineBlockUsage $usage, SectionStorageManagerInterface $section_storage_manager) {

@@ -63,7 +64,7 @@ public static function create(ContainerInterface $container) {
-      $container->get('database')
+      $container->get('plugin.manager.layout_builder.section_storage')

I don't think removing the DB parameter is in scope, is it?

At least the typehints are different so it will cleanly fatal vs. having weird bugs, but we are moving away from constructor breaks in general even for "internalish" code. See #3030640: [policy, documentation] Clarify Constructor BC policy and document best practices for subclassing other classes.

xjm’s picture

A related followup woulod be to explain the "why" in the @internal. Is it because LB is experimental? Because subclassing this is a totally bad idea? Etc.

xjm’s picture

...Clarifying #38, the "more BC" way to change the constructor is to keep the DB service param, and make the new section storage param optional with a fallback to \Drupal::service() that @trigger_error()s.

tedbow’s picture

  1. re #37 lets go with https://www.drupal.org/node/3030609. I don't have permission to delete the other one but if we can we should.
  2. re #38 and #40 Adding parameter as optional for now.

    I chatted with @xjm about this and since we also have an used $database parameter to the constructor(existing problem) there is not clear answer for what to do. For that reason I am not throwing @trigger_error because there is not a clear recommendation.
    added follow up. #3031492: Remove @todo in InlineBlockEntityOperations constructor and also referenced #3030640: [policy, documentation] Clarify Constructor BC policy and document best practices for subclassing other classes

  3. re #39 made this follow up #3030640: [policy, documentation] Clarify Constructor BC policy and document best practices for subclassing other classes. I think it should not be subclassed but maybe there is good argument to.
xjm’s picture

+++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
@@ -43,18 +44,31 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
+   * @todo This constructor has 1 optoinal parameter, $section_storage_manager,
+   *    and 1 totally unused $database parameter. Deprecate the current

"Optoinal" sounds like a non-Western musical scale. ;)

Also, nit: we should spell out the word "one" in a sentence. (I think the rule they taught me in grade school was to spell out numbers less than or equal to ten.)

Status: Needs review » Needs work

The last submitted patch, 41: 3026434-41.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB
new14.77 KB
  1. "Optoinal" sounds like a non-Western musical scale. ;)

    I can neither confirm or deny 😜
    fixed.

  2. Also I misspelled compatibility. Fixed
  3. lso, nit: we should spell out the word "one" in a sentence.

    fixed

  4. Canceling previous test to save resources
tedbow’s picture

StatusFileSize
new906 bytes
new14.76 KB

pointed out by @tim.plunkett

+++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
@@ -43,17 +44,31 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
+   *    and one  totally unused $database parameter. Deprecate the current

extra space "one totally"

tim.plunkett’s picture

Interdiff looks good, all of the feedback since the last RTBC seems to have been addressed.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 45: 3026434-45.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community

Drupal\Tests\media\FunctionalJavascript\MediaStandardProfileTest random fail

xjm’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
@@ -43,17 +44,31 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
+    if ($section_storage_manager === NULL) {
+      $this->sectionStorageManager = \Drupal::service('plugin.manager.layout_builder.section_storage');
+    }
+    else {
+      $this->sectionStorageManager = $section_storage_manager;
+    }

The @trigger_error() is missing here in the if.

Also, we could get rid of the else for easier future deprecation cleanup, by setting $section_storage_manager instead in the if, and then just setting $this->sectionStorageManager thereafter outside of any conditional.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new948 bytes
new14.74 KB

The @trigger_error() is missing here in the if.

see #41.2
I was hoping we could address this in the follow up #3031492: Remove @todo in InlineBlockEntityOperations constructor

otherwise would have to trigger_error would have to give a recommendation now and but then the follow up might change the constructor signature again so we would have new recommendation.

Was hoping we could just ask developers to update there code once. But I am not sure here

Fixed the other point in #50

tedbow’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1002 bytes
new14.99 KB

I talked with @xjm and now understand what was asked for in #50.

Here is it is.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 52: 3026434-52.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB
new14.99 KB

Fixed standard nits

The last submitted patch, 52: 3026434-52.patch, failed testing. View results

phenaproxima’s picture

  1. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -43,17 +44,30 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
    +   * @param \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager
    +   *   The section storage manager.
    

    Nit: I think this parameter description needs to be prefixed with (optional).

  2. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -85,10 +100,7 @@ protected function removeUnusedForEntityOnSave(EntityInterface $entity) {
         if ($entity->isNew() || !isset($entity->original) || $entity instanceof RevisionableInterface) {
           return;
         }
    -    $sections = $this->getEntitySections($entity);
    -    // If this is a layout override and there are no sections then it is a new
    -    // override.
    -    if ($this->isEntityUsingFieldOverride($entity) && empty($sections)) {
    +    if ($this->originalEntityUsesDefaultStorage($entity)) {
    

    It looks like the call to $this->originalEntityUsesDefaultStorage() could be merged into the preceding if statement.

  3. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -93,6 +100,35 @@ protected function getInlineBlockComponents(array $sections) {
    +    if ($entity instanceof LayoutBuilderEntityViewDisplay) {
    

    Should this type hint to LayoutEntityDisplayInterface instead?

  4. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -93,6 +100,35 @@ protected function getInlineBlockComponents(array $sections) {
    +        if ($display instanceof LayoutBuilderEntityViewDisplay) {
    +          $contexts['display'] = EntityContext::fromEntity($display);
    +        }
    

    Discussed in Slack with @tedbow and @xjm; Given the way Layout Builder works (it takes over the entity_view_display entity type) I'm not sure this instanceof check is actually needed. Although this also isn't really hurting anything, I don't see why we bother to check.

  5. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -101,9 +137,39 @@ protected function getInlineBlockComponents(array $sections) {
    +      if ($original_section_storage instanceof DefaultsSectionStorageInterface) {
    +        // If there were no sections in the original entity the storage will
    +        // revert to the default storage and this is a new override.
    +        return TRUE;
    +      }
    

    To remove yet another level of indentation, this can just be return $original_section_storage instanceof DefaultsSectionStorageInterface.

  6. +++ b/core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php
    @@ -0,0 +1,66 @@
    +    $this->assertEquals($expected, $method->invoke($test_class, $entity));
    

    Any reason not to use assertSame() here?

tedbow’s picture

StatusFileSize
new4.61 KB
new14.99 KB
  1. fixed
  2. I didn't move this to the previous if but added comment to say why are returning here. I think the comment was needed and it is more readable to break this logic out.
  3. fixed
  4. removed the check
  5. fixed
  6. changed

Status: Needs review » Needs work

The last submitted patch, 57: 3026434-57.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new925 bytes
new15.06 KB

re #56.4
Now I remember why we need this. This migrate test fails without it. I don't think it is bad check to have.

A could swap this our for one entity type. Who knows why. Modules do strange things

phenaproxima’s picture

Status: Needs review » Needs work

Briefly discussed with @tedbow and @xjm and I think we are going to need explicit test coverage of the new trait methods too.

kristen pol’s picture

Since this needs work anyway, I noticed a couple tiny nitpicks.

  1. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -43,17 +44,30 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
    +   * @todo This constructor has one optional parameter, $section_storage_manager
    +   *    and one totally unused $database parameter. Deprecate the current
    +   *    constructor signature in https://www.drupal.org/node/3031492 after the
    +   *    general policy for constructor backwards compatibility is determined in
    +   *    https://www.drupal.org/node/3030640.
    

    Nitpick: One extra space before and, constructor, general, https. (3 spaces instead of 2)

  2. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -93,6 +100,35 @@ protected function getInlineBlockComponents(array $sections) {
    +   *   The section storage if found otherwise NULL.
    

    Nitpick: Add comma before otherwise.

tim.plunkett’s picture

StatusFileSize
new18.51 KB
new5.37 KB

Here's a WIP test

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new15.61 KB
new29.08 KB

@tim.plunkett thanks for the WIP test.

I finished the test coverage for the trait. I used unit tests when I could and kernel tests where I had to.

tedbow’s picture

StatusFileSize
new29.08 KB

whoops name the patch wrong

Status: Needs review » Needs work

The last submitted patch, 64: 3026434-internals-63.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new1.09 KB
new30.17 KB

Ok this cause what seemed to be an unrelated test failure in \Drupal\KernelTests\Core\Asset\ResolvedLibraryDefinitionsFilesMatchTest::setUp() but it turns out is related but just a problem with that kernel test. Let me explain....

  1. This tests install all modules except demo_umami_content because that module makes demo content and requires tables that are not present in the kernel test.
  2. workspaces_install() creates a new workspace with the default uid of 1 if no other user is present.
  3. There will be no user table present in the kernel test but this does not cause an exception before this patch because no actual validation is present.
  4. This patch adds a hook_entity_presave which ultimately pass the entity has context to \Drupal\layout_builder\SectionStorage\SectionStorageManager::findByContext().
  5. This in turn will cause the validation to be run on the entity which will call \Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator::validate()
  6. This will cause an exception because it will try to query the user table does not exist.

There are a few ways we can solve this problem in the test

  1. Don't install workspaces like demo_umami_content because it also requires a table which is not present.
  2. Ensure that layout_builder is installed after workspaces so the hook_entity_presave is not present. doesn't fix it
  3. Call $this->installEntitySchema('user'); in the test before all modules are installed.

This patch does 3) which I think is the best.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

#3035825: Make it easier to set up the current_user service in kernel tests will be installing the user entity schema in many many more tests, so I think that change is more than reasonable here.

Tests look good!

The last submitted patch, 62: 3026434-internals-62.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Layout Builder stable blocker

OK, I didn't get through the whole patch (this is hard to grok!) but here are questions and feedback I had while reviewing it down to the tests:

  1. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -43,17 +44,30 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
    +   * @todo This constructor has one optional parameter, $section_storage_manager
    +   *    and one totally unused $database parameter. Deprecate the current
    +   *    constructor signature in https://www.drupal.org/node/3031492 after the
    +   *    general policy for constructor backwards compatibility is determined in
    +   *    https://www.drupal.org/node/3030640.
    

    @todos go at the bottom of the dockblock. Also, it's a little hard to read. How about:

    @todo The current constructor signature is deprecated:
      - The $section_storage_manager paeameter is optional, but should become required.
      - The $database parameter is unused and should be  removed.
      Deprecate in https://www.drupal.org/node/3031492.
    
  2. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -43,17 +44,30 @@ class InlineBlockEntityOperations implements ContainerInjectionInterface {
    -  public function __construct(EntityTypeManagerInterface $entityTypeManager, InlineBlockUsage $usage, Connection $database) {
    +  public function __construct(EntityTypeManagerInterface $entityTypeManager, InlineBlockUsage $usage, Connection $database, SectionStorageManagerInterface $section_storage_manager = NULL) {
    

    I added a line at the end of the CR for this.

    "Additionally InlineBlockEntityOperations has been updated to use the section storage manager, but this is unlikely to affect any extending code."

  3. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -85,10 +100,10 @@ protected function removeUnusedForEntityOnSave(EntityInterface $entity) {
    +    // If the original entity used the default storage then we cannot remove
    +    // unused inline blocks because they will still be referenced in the
    +    // defaults.
    

    What if the default storage only uses some of the inline blocks, or totally different ones? How do these get cleaned up? Is there a mechanism to clean them up manually?

  4. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -132,9 +147,9 @@ protected function getRemovedBlockIds(EntityInterface $entity) {
    -    if ($this->isLayoutCompatibleEntity($entity)) {
    -      $this->usage->removeByLayoutEntity($entity);
    -    }
    +    // @todo In https://www.drupal.org/node/3008943 call
    +    //   \Drupal\layout_builder\LayoutEntityHelperTrait::isLayoutCompatibleEntity().
    +    $this->usage->removeByLayoutEntity($entity);
    

    How is this change a part of the patch? Why do we now need #3008943: Clean up todo in InlineBlockEntityOperations::handleEntityDelete() when we didn't before?

  5. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -93,6 +100,35 @@ protected function getInlineBlockComponents(array $sections) {
    +      $contexts['display'] = EntityContext::fromEntity($entity);
    ...
    +      $contexts['entity'] = EntityContext::fromEntity($entity);
    

    At first it looked like this line was exactly the same in both codepaths, but one is setting $contexts['display] and the other is setting $contexts['entity'] (and then $contexts['display'] gets set later to something else). So this is correct, but an inline comment in each of the if and the else might be helpful to describe what they're doing.

  6. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -101,9 +137,47 @@ protected function getInlineBlockComponents(array $sections) {
    +   * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0.
    +   *   To determine if an entity has an layout override use
    +   *   \Drupal\layout_builder\LayoutEntityHelperTrait::getSectionStorageForEntity()
    +   *   and check if the result is an instance of
    +   *   \Drupal\layout_builder\DefaultsSectionStorageInterface
    +   *   See https://www.drupal.org/node/3030609.
    

    Typos here. It should say:

    To determine if an entity has a layout override, use \Drupal\layout_builder\LayoutEntityHelperTrait::getSectionStorageForEntity() and check whether the result is an instance of \Drupal\layout_builder\DefaultsSectionStorageInterface.

    And then the "See" should be moved into an @see.

  7. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -101,9 +137,47 @@ protected function getInlineBlockComponents(array $sections) {
    +   * Determines if the original entity used the default storage.
    

    This could give a little more explanation.

  8. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -101,9 +137,47 @@ protected function getInlineBlockComponents(array $sections) {
    +  protected function originalEntityUsesDefaultStorage(EntityInterface $entity) {
    +    $section_storage = $this->getSectionStorageForEntity($entity);
    +    if ($section_storage instanceof OverridesSectionStorageInterface && !$entity->isNew() && isset($entity->original)) {
    +      $original_section_storage = $this->getSectionStorageForEntity($entity->original);
    +      // If there were no sections in the original entity the storage will
    +      // revert to the default storage and this is a new override.
    +      return $original_section_storage instanceof DefaultsSectionStorageInterface;
    +    }
    +    return FALSE;
    +  }
    

    So this method is essentially checking whether the updated entity:

    1. has a layout override,
    2. is not a brand-new entity,
    3. is being updated and differs from the previous entity, and
    4. previously had no override and just used the defaults.

    In a nutshell, whether a new override layout is being created for the entity in this update operation.

    The method name kind of confused me when I read it in calling code. I think there's already been discussion about what this could be called and I don't want to put too much Naming Things in here, but just flagging for now that it tripped me up reading the code.

  9. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -101,9 +137,47 @@ protected function getInlineBlockComponents(array $sections) {
    +  /**
    +   * Gets the section storage manager.
    +   *
    +   * @return \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface
    +   *   The section storage manager.
    +   */
    +  private function sectionStorageManager() {
    +    return $this->sectionStorageManager ?: \Drupal::service('plugin.manager.layout_builder.section_storage');
    +  }
    

    So I would have expected this fallback in the constructor itself for BC, but it's here in the trait. Seems odd/wrong for a trait to have dependencies on services or be falling back to \Drupal. Why is it on the trait?

Apparently this hard-blocks a stable blocker, so tagging accordingly.

Thanks!

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new3.76 KB
new30.55 KB

@xjm thanks for the review!

  1. fixed
  2. thanks for CR update.
  3. originalEntityUsesDefaultStorage() will only return true for an override that was just created/copied from a default.

    in that case we don't want to remove any inline blocks. They will still be used in the default.

    This logic is effectively the same as what is in 8.7.x but was using the previous methods

    // If this is a layout override and there are no sections then it is a new
        // override.
        if ($this->isEntityUsingFieldOverride($entity) && empty($sections)) {
          return;
        }
    
    How do these get cleaned up? Is there a mechanism to clean them up manually?

    When saving a LayoutBuilderEntityViewDisplay entity which is where the defaults are stored originalEntityUsesDefaultStorage() will not return TRUE so the inline blocks that are no longer referenced will be removed just after this by

    // Delete and remove the usage for inline blocks that were removed.
        if ($removed_block_ids = $this->getRemovedBlockIds($entity)) {
          $this->deleteBlocksAndUsage($removed_block_ids);
        }
    
  4. Before this patch isLayoutCompatibleEntity() was simply doing this
    return $entity instanceof LayoutEntityDisplayInterface || $this->isEntityUsingFieldOverride($entity);
    

    So it only worked for by knowing about how both override and default section storages stored the sections which should be internal to the plugin. Also this method would never work for any other section storage plugins.

    So it was changed to this
    return $this->getSectionStorageForEntity($entity) !== NULL; which should work for any entity that has layout section storage and doesn't need to know any details about how any section storage stores their sections.

    The problem is that in getSectionStorageForEntity() we pass the entity that was just deleted to return $this->sectionStorageManager()->findByContext($contexts, new CacheableMetadata());

    Hence the error from #3008943: Clean up todo in InlineBlockEntityOperations::handleEntityDelete(). After that is fixed we can call the new version of isLayoutCompatibleEntity() without an error.

    Not calling isLayoutCompatibleEntity() just means that we are calling \Drupal\layout_builder\InlineBlockUsage::removeByLayoutEntity() sometimes when we don't need to if we knew the entity was not layout compatible.

    But calling removeByLayoutEntity() is not the end of the world since it would just update the any row in the inline_block_usage table that match the entity type and entity id for the deleted entity. But since there should never be blocks that reference the non-compatible entities it will have not effect. Just a update we can save after #3008943: Clean up todo in InlineBlockEntityOperations::handleEntityDelete() is fixed.

  5. I wrote out the comments but it felt like I was just translating the code into english not actually explaining anthing.
    for instance
    
    if ($entity instanceof LayoutEntityDisplayInterface) {
          $contexts['display'] = EntityContext::fromEntity($entity);
        }

    My comment would be
    // If the entity is an instance of LayoutEntityDisplayInterface set it is has the 'display' context.

    I could extra information about how this is used by defaults section storage but from the section manager perspective this could used by other section storages we don't know about. So I don't want to then add back assumptions about certain section storage plugins if we don't have to.

    I agree the diff is confusing but I am not sure the new code is confusing if you didn't know about the previous version.

    I can add them if you still think it is needed.

  6. fixed
  7. added more detail.
  8. Hopefully the comment would make it more clear.

    I really really really don't want to rename this function entityHasNewOverride()

    We need this function to determine if it is the original entity was using default as far as the inline blocks is concerned. This may not always be what is considered a "new override" especially after #2946333: Allow synced Layout override Translations: translating labels and inline blocks.

    I explained my reasoning in #34 further.

    I removed the internal comment that was left over and mentioned "new override".

    I would also be happy to move this back to InlineBlockEntityOperations and off of LayoutEntityHelperTrait if we want to keep this solely for inline blocks logic.

  9. @tim.plunkett add this will check with him.

    Actually I remember..... It is on the trait because we can't be sure someone isn't already using the trait in another class and we can't update their constructor(even though our trait is @internal)

Status: Needs review » Needs work

The last submitted patch, 70: 3026434-internals-70.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review

#71 was random fail in MediaStandardProfileTest 😢unrelated but would probably be fixed by #2901792: Disable all animations in Javascript testing

Status: Needs review » Needs work

The last submitted patch, 70: 3026434-internals-70.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

I believe #70 addresses all of the concerns from #69, and the changes look good. Setting back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 70: 3026434-internals-70.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Reviewed & tested by the community

I am not sure where the test failure is for #76. When I clicked the link https://www.drupal.org/pift-ci-job/1218142

It says all tests passed. the patch still applies and it looks like someone queued for retesting

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This looks really close - only a few minor nits.

  1. +++ b/core/modules/layout_builder/src/InlineBlockEntityOperations.php
    @@ -150,14 +171,10 @@ public function handlePreSave(EntityInterface $entity) {
    -      if ($this->isEntityUsingFieldOverride($entity)) {
    -        if (!$entity->isNew() && isset($entity->original)) {
    -          if (empty($this->getEntitySections($entity->original))) {
    -            // If there were no sections in the original entity then this is a
    -            // new override from a default and the blocks need to be duplicated.
    -            $duplicate_blocks = TRUE;
    -          }
    -        }
    +      if ($this->originalEntityUsesDefaultStorage($entity)) {
    +        // This is a new override from a default and the blocks need to be
    +        // duplicated.
    +        $duplicate_blocks = TRUE;
           }
    

    My head hurts less. Nice.

  2. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -62,13 +74,8 @@ protected function getInlineBlockRevisionIdsInSections(array $sections) {
    -    return NULL;
    +    $section_storage = $this->getSectionStorageForEntity($entity);
    +    return $section_storage ? $section_storage->getSections() : [];
    

    We're slightly changing the return type here. I think an empty array makes more sense but then we need to update the docs to remove |null. Also the docs have an @todo - is that done now?

  3. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -101,9 +137,50 @@ protected function getInlineBlockComponents(array $sections) {
    +    return $this->sectionStorageManager ?: \Drupal::service('plugin.manager.layout_builder.section_storage');
    

    Should the NULL case be deprecated? I always find traits and services tricky.

  4. +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php
    @@ -108,6 +108,12 @@ protected function setUp() {
    +    // Install the 'user' entity schema because the workspaces module's install
    +    // hook creates a workspace with default uid of 1. Then the layout_builder
    +    // module's implementation of hook_entity_presave will cause
    +    // \Drupal\Core\TypedData\Validation\RecursiveValidator::validate() to run
    +    // on the workspace which will fail because the user table is not present.
    

    That's funky. That's probably worth a follow to fix workspaces to not create a workspace when user does not exist.

  5. +++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
    @@ -15,6 +20,13 @@
    +  /**
    +   * The section storage manager.
    +   *
    +   * @var \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface
    +   */
    +  protected $sectionStorageManager;
    

    I think we should document that we should document that classes using this trait are expected to set this.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new31.06 KB
new2.08 KB

#79

2)
Fixed. Also, that todo points to an issue that this one duplicates. I'll close it.

3)
I have no problem leaving this as it is. I think deprecating is too prescriptive here, there's nothing actually wrong with the service call IMO.

4)
Opened #3039217: ResolvedLibraryDefinitionsFilesMatchTest needs to install the user entity schema

5)
Given my take on 3, I don't think this is needed. The only time this would matter is during unit testing.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/layout_builder/src/LayoutEntityHelperTrait.php
@@ -101,9 +133,50 @@ protected function getInlineBlockComponents(array $sections) {
+      $original_section_storage = $this->getSectionStorageForEntity($entity->original);
+      return $original_section_storage instanceof DefaultsSectionStorageInterface;

Nit: This could be a single (albeit very long) line.

Feedback looks pretty solidly addressed to me, and I agree that the logic surrounding originalEntityUsesDefaultStorage() is a lot cleaner. I only skimmed the tests, but the coverage looks (at a glance) comprehensive. Seeing as how this already seems to have @alexpott's blessing, I'm not sure there's much more for me to do here but RTBC this.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 09a6d81ec9 to 8.8.x and 70b46d5554 to 8.7.x. Thanks!

I'm not 100% convinced on the usage of \Drupal::service() in traits but this trait is far from alone and service location is a massive issue and fixing the way we do it far beyond the scope here so /shrug.

tim.plunkett’s picture

Status: Fixed » Reviewed & tested by the community

This was not successfully pushed

  • alexpott committed 30654bd on 8.8.x
    Issue #3026434 by tedbow, tim.plunkett, xjm, phenaproxima, plach,...
alexpott’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

hint: Updates were rejected because the tip of your current branch is behind sorry :(

Pushing to 8.8.x now and will backport to 8.7.x once we're out of the freeze. Committed 30654bd41d and pushed to 8.8.x. Thanks!

alexpott’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

Setting the correct status.

  • alexpott committed 6a6516a on 8.7.x
    Issue #3026434 by tedbow, tim.plunkett, xjm, phenaproxima, plach,...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

  • xjm committed cfd9c0b on 8.7.x
    Revert "Issue #3026434 by tedbow, tim.plunkett, xjm, phenaproxima, plach...
xjm’s picture

Status: Fixed » Reviewed & tested by the community

We're still in commit freeze, so reverted from 8.7.x for now.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

  • alexpott committed fe14b75 on 8.7.x
    Issue #3026434 by tedbow, tim.plunkett, xjm, phenaproxima, plach,...

Status: Fixed » Closed (fixed)

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

quietone’s picture

publish change record