Needs work
Project:
Drupal core
Version:
main
Component:
layout_builder.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Feb 2019 at 16:49 UTC
Updated:
20 Feb 2024 at 13:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
tim.plunkettComment #3
phenaproximaThis patch makes perfect sense to me.
Comment #4
xjmDiscussed with @tim.plunkett. In our API policy, paramconverters are listed as an example of the
@internalthings that people shouldn't extend (to the point that people want to putfinalon 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. 🎄
Comment #5
tim.plunkettI'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:
LayoutSectionStorageParamConverterThis class is responsible for taking a
section_storage_typestring and the rest of the routing information and populating thesection_storagevalue.This fits with the purpose of param converters
LayoutTempstoreRouteEnhancerThis 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.
Comment #6
tim.plunkettComment #7
phenaproximaYup, 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.
Comment #9
tim.plunkett#2946294: Fix race conditions in OffCanvasTestBase random fail, requeueing
Comment #10
tim.plunkettReroll after post_update conflict.
Comment #13
tim.plunkettI think that was a testbot fluke
Comment #14
xjmSo the new approach is splitting up the old
LayoutTempstoreParamConverter, renaming it toLayoutSectionStorageParamConverter, and addingLayoutTempstoreRouteEnhancer.This is internal code, but maybe a CR would be in order?
Comment #15
alexpottNeeds a reroll as well as a change record.
Comment #16
tim.plunkettWill try to remember to work on soon, but not assigning for now.
Comment #17
vacho commentedOnly patch reroll
Comment #18
yogeshmpawarMoving to Needs Review & Triggering bots.
Comment #20
tim.plunkettMarking "needs work" for the change record.
Comment #24
neclimdulre-roll around #3106666: Remove post updates added prior to 8.8.0
Comment #25
clayfreemanCR posted here. Restoring RTBC.
Comment #27
alexpottCommitted 6eee1db and pushed to 9.3.x. Thanks!
Comment #28
neclimdulHey past me, do you remember why you where interested in this and what you can fix going forward?
Comment #29
clayfreeman@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?)
Comment #30
clayfreemanFound it.
Comment #32
seanbThis 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())inDrupal\Core\Access\AccessManager::checkNamedRoute. Since theAccessManagerdoes not call route enhancers, the code inLayoutTempstoreRouteEnhanceris never called, which leads to the "wrong" version of the SectionStorage and anOutOfBoundsExceptionwhen 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
LayoutTempstoreRepositoryservice?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.
Comment #34
clayfreemanPer 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.
Comment #35
tim.plunkettComment #36
tim.plunkettI 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.
Comment #37
clayfreeman@tim.plunkett isn't that already covered by the combination of
\Drupal\Tests\Core\Access\AccessManagerTestand\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.
Comment #38
tim.plunkett#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.
Comment #39
clayfreemanAdding 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.
Comment #40
clayfreemanWhoops -- accidentally attached an empty patch.
Comment #41
clayfreemanReady for review!
Comment #42
jeremyvii commentedThe added test LGTM.
Comment #43
quietone commentedThis 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?
Comment #44
clayfreeman@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.
Comment #45
nod_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.
Comment #46
bhanu951 commentedComment #47
bhanu951 commented@clayfreeman : Can you update the target branch to 10.1.x ?
Comment #48
clayfreemanComment #49
smustgrave commentedSeems there were some erros in the MR 1549
Did not test or review yet.
Comment #51
wilfred waltman commentedHere is a patch for Drupal 10.2 based on latest MR.
Comment #52
bhanu951 commented@clayfreeman : Can you update the target branch to 11.x ?