Problem/Motivation

When given the section storage in tempstore it is very difficult (almost impossible) to retrieve the raw section storage underneath.

Currently, the only param converter provided does all the loading of the section storage but also passes it through tempstore first.

Proposed resolution

Provide a param converter that simply loads the section storage.
Move the tempstore loading to a route enhancer

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3032433

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

Status: Active » Needs review
FileSize
14.97 KB
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

This patch makes perfect sense to me.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Discussed with @tim.plunkett. In our API policy, paramconverters are listed as an example of the @internal things that people shouldn't extend (to the point that people want to put final on them). But this issue is definitely adding one paramconverter that extends another, which is either a counterpoint to "all paramconverters are internal" because we want to do something useful here for it, or it means we need to change what this patch does to match the current BC policy and set a good example.

@tim.plunkett is going to change this to use decoration instead. 🎄

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
13.43 KB
12.59 KB

I'm not sure what I was thinking when I suggested decorating it. That would defeat the purpose, as the inner decorated service is effectively replaced.

Thinking about this more, I decided to go with this split:

LayoutSectionStorageParamConverter

This class is responsible for taking a section_storage_type string and the rest of the routing information and populating the section_storage value.
This fits with the purpose of param converters

LayoutTempstoreRouteEnhancer

This class takes an existing SectionStorageInterface object and replaces it with one from the tempstore.
This also fits better with a route enhancer rather than a param converter.

tim.plunkett’s picture

Title: Provide a separate param converter to load a section storage without tempstore » Allow section storages to be loaded via routing without loading from the tempstore
Issue summary: View changes
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Yup, this is a lot better; it's free of questionable patterns and the tests make sense to me. For whatever my rather promiscuous word is worth, I say let's go for it.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 3032433-enhancer-5.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community
tim.plunkett’s picture

Reroll after post_update conflict.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: 3032433-enhancer-10.patch, failed testing. View results

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.

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community

I think that was a testbot fluke

xjm’s picture

Issue tags: +Needs change record

So the new approach is splitting up the old LayoutTempstoreParamConverter, renaming it to LayoutSectionStorageParamConverter, and adding LayoutTempstoreRouteEnhancer.

This is internal code, but maybe a CR would be in order?

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Needs a reroll as well as a change record.

tim.plunkett’s picture

Issue tags: +Needs reroll

Will try to remember to work on soon, but not assigning for now.

vacho’s picture

Issue tags: -Needs reroll
FileSize
13.49 KB

Only patch reroll

yogeshmpawar’s picture

Status: Needs work » Needs review

Moving to Needs Review & Triggering bots.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tim.plunkett’s picture

Status: Needs review » Needs work

Marking "needs work" for the change record.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

neclimdul’s picture

clayfreeman’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

CR posted here. Restoring RTBC.

  • alexpott committed 6eee1db on 9.3.x
    Issue #3032433 by tim.plunkett, neclimdul, vacho, xjm, phenaproxima:...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6eee1db and pushed to 9.3.x. Thanks!

neclimdul’s picture

Hey past me, do you remember why you where interested in this and what you can fix going forward?

clayfreeman’s picture

@neclimdul

I unironically had the same question. I believe it was due to caching misbehaving for the layout override local task, but I could be misremembering. (Is that even a separate issue? Or is this enough to solve that problem?)

clayfreeman’s picture

Status: Fixed » Closed (fixed)

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

seanB’s picture

This seems to have caused a regression in custom access checks for layout builder routes, like the access checks in the Layout Builder Advanced Permissions module.

The access checks used to receive the SectionStorage from the temp store, since the AccessManager calls $this->paramConverterManager->convert($parameters + $route->getDefaults()) in Drupal\Core\Access\AccessManager::checkNamedRoute. Since the AccessManager does not call route enhancers, the code in LayoutTempstoreRouteEnhancer is never called, which leads to the "wrong" version of the SectionStorage and an OutOfBoundsException when calling $section_storage->getSection($delta) for a newly added section (only available in the tempstore).

I don't understand route enhancers and param converters well enough to decide if this is a bug or not, so I'm not sure we should open a new issue, revert this change, or just accept that access checks for layout builder should fetch the section storage from the temp store themselves using the LayoutTempstoreRepository service?

Created #3253819: In 9.3.x the SectionStorage in the AccessManager is no longer loaded from the temp store as a workaround for the Layout Builder Advanced Permissions module.

clayfreeman’s picture

Per our conversation in Slack, I believe the original concern of this issue would be better served by moving the enhancement functionality back to the param converter. This way routes can still use the new flag that was introduced (the "public" portion of the API changes) to avoid the tempstore, while existing code shouldn't need to change.

Will need a maintainer to reopen this and set it to Needs Review.

tim.plunkett’s picture

Status: Closed (fixed) » Needs review
tim.plunkett’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

I think it's be good to have a test demonstrating the problem, that access checking routes containing a section storage no longer (but will now, with this change) get the tempstore version.

clayfreeman’s picture

@tim.plunkett isn't that already covered by the combination of \Drupal\Tests\Core\Access\AccessManagerTest and \Drupal\Tests\layout_builder\Unit\LayoutSectionStorageParamConverterTest? The former test class ensures that the access manager uses parameter conversion for route access checks, where the latter ensures that the Layout Builder flags produce the correct value during conversion. If both tests pass, then it would logically follow that the correct behavior is observed in Layout Builder access checks, no?

I'm down to add this additional test case if needed, but I also want to avoid duplicating any test functionality. I'm also not sure how I would test the currently-released 9.3.0 behavior after making the changes contained within my proposed revision if that's what you mean instead.

tim.plunkett’s picture

#32 describes a contrib module that is broken now, after the commit from#26. And presumably would be fixed by your MR.
We should be able to write a non-unit test (emulating that contrib approach or not) that fails in 9.3.x and passes with your MR. Something that triggers access checking on an LB route, and proves that the section storage being passed into an access checker is NOT loaded from tempstore.

The reason I say not a unit test, is because that's where our mistake stems from before: when the test coverage is tied directly to the effects of a given class, we could lose coverage when that class is refactored/repurposed. If we have a functional test that doesn't care about which class is responsible, but rather the effect of the combination of classes, then we'll be covered.

clayfreeman’s picture

Adding test-only patch which should fail against 9.3.x/HEAD. Will follow-up by including this in the MR, which should hopefully then pass.

clayfreeman’s picture

FileSize
14.19 KB

Whoops -- accidentally attached an empty patch.

clayfreeman’s picture

Status: Needs work » Needs review

Ready for review!

jeremyvii’s picture

Status: Needs review » Reviewed & tested by the community

The added test LGTM.

quietone’s picture

Version: 9.3.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Needs work

This issue was committed in 9.3.x and then re-opened a few months later. Should the work after the commit be in a separate issue? I ask because from working in the Bugsmash Initiative issues that are committed and then re-opened (without a revert of the commit) tend to linger and be difficult to triage. It is also extra work when searching git logs when more that one commit has the same issue number and different changes.

The work on the MR, this will need to be on 10.0.x.

This is tagged as 'Needs tests' but I took a brief view of the MR and see that there are tests. Are the tests here sufficient or do they need work?

clayfreeman’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

@quietone

At least in my mind, I'm treating this issue as a "revert and fix" since the original issue summary is still valid, even if reverted. (The original issue isn't "fixed" if you will.)

Rebased on 10.0.x.

I think "Needs tests" can be removed, subject to additional review by Tim.

nod_’s picture

Version: 10.0.x-dev » 10.1.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

D10 version needed
At this time we need a D10.1.x patch or MR for this issue.

Patch or MR doesn't apply anymore
The last patch or MR doesn't apply to the target branch, please reroll the code so that it can be reviewed by the automated testbot.

Bhanu951’s picture

Assigned: Unassigned » Bhanu951
Bhanu951’s picture

Assigned: Bhanu951 » Unassigned
Issue tags: -Needs reroll

@clayfreeman : Can you update the target branch to 10.1.x ?

clayfreeman’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Seems there were some erros in the MR 1549

Did not test or review yet.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Wilfred Waltman’s picture

FileSize
27.18 KB

Here is a patch for Drupal 10.2 based on latest MR.

Bhanu951’s picture

@clayfreeman : Can you update the target branch to 11.x ?