Problem/Motivation

There are cases (at least in our setup) which the sfc_unique_id is not actually unique when SFCs are nested within eachother. I think this has to do with how twig templates handle variables that are present in both inner and outer embed/include templates. Going to create a MR that helps to ensure that nested SFCs reliably get assigned their own unique ID as opposed to inheriting from the parent.

Steps to reproduce

Embed/include an SFC inside of another {% embed "sfc--foo.html.twig" %}.

Proposed resolution

Track generated unique IDs in a static variable to help ensure that all IDs are truly unique.

CommentFileSizeAuthor
#5 3309555-5.patch2.65 KBsamuel.mortenson

Issue fork sfc-3309555

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mrweiner created an issue. See original summary.

mrweiner’s picture

Status: Active » Needs review
samuel.mortenson’s picture

@mrweiner Nice issue. I think you can get around this by using the "only" keyword but your fix seems like a good idea.

samuel.mortenson’s picture

StatusFileSize
new2.65 KB

Added tests, fixed PHPCS errors.

samuel.mortenson’s picture

Test failures appear to be a core bug:

>>> \Drupal::getContainer()->get('app.root')
<warning>PHP Deprecated:  The "app.root" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612 in /home/mortenson/repos/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php on line 134</warning>
=> "/home/mortenson/repos/drupal"
>>> \Drupal::getContainer()->getServiceIdMappings()
<warning>PHP Deprecated:  The "app.root" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612 in /home/mortenson/repos/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php on line 134</warning>
TypeError: Argument 1 passed to Drupal\Component\DependencyInjection\Container::generateServiceIdHash() must be an object, string given, called in /home/mortenson/repos/drupal/core/lib/Drupal/Component/DependencyInjection/ServiceIdHashTrait.php on line 19

Ref #2531564: Fix leaky and brittle container serialization solution

  • e16ce1c committed on 8.x-1.x
    Issue #3309555 by mrweiner, samuel.mortenson: sfc_unique_id may be...
samuel.mortenson’s picture

Status: Needs review » Fixed

Thanks again!

samuel.mortenson’s picture

I've just released 8.x-1.8 as well if you'd like to update.

mrweiner’s picture

Yeah I actually came across only after I opened this. We're now using it to address a variety of inheritance issues, but glad this was helpful nonetheless!

Status: Fixed » Closed (fixed)

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