Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Reverting a Layout doesn't work if you have adding new block to the layout before you click "Revert to defaults". though the message still says you reverted. Here is test addition for that. It will fail now.
Comment | File | Size | Author |
---|---|---|---|
#16 | 2970801-revert-15.patch | 3.08 KB | tim.plunkett |
#16 | 2970801-revert-15-interdiff.txt | 1.66 KB | tim.plunkett |
#10 | interdiff-2970801-5-10.txt | 1.42 KB | victor-shelepen |
#10 | 2970801-10.patch | 5.81 KB | victor-shelepen |
#5 | 2970801-5.patch | 4.65 KB | tedbow |
Comments
Comment #2
tedbowComment #4
tedbowNot sure why this works but posting to see if anyone else knows.
got this idea from @johndevman
Who was testing and found the test passes if
1) didn't seem like good idea so tried 2)
Comment #5
tedbowOk, this fix makes sense because
\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::getEntity
it going to get the entity with the sections before the latest block is added.I cleaned up the fix to use inject the section storage manager. I am keeping loading the section storage manager in
submitForm()
because it should be loaded at the last possible time before reverting.Also added commented in the test to explain why we add a block.
Comment #6
sjerdoWorks like a charm. Code seems good.
Comment #7
tedbow@sjerdo thanks for testing this out
@tim.plunkett wanted to take a look at this because we might need to change some routing level items not send the
$section_storage
to::buildForm()
So setting back to needs review.
Comment #8
tim.plunkettNW for #7
Comment #10
victor-shelepen CreditAttribution: victor-shelepen as a volunteer commentedI checked the 5th patch. It worked well. I did some modifications. The
$section_storage
has been moved to::buildForm(
). So we do need pass $section_storage as a parameter on Route API level that is mentioned in [#2970801#7]Comment #11
victor-shelepen CreditAttribution: victor-shelepen as a volunteer commentedThe current node is getting from the route. It can also be gotten from the context handler. It is not clear how to get a section storage type and an entity type if it is needed for another cases. Now they are variables defined strictly.
Comment #12
victor-shelepen CreditAttribution: victor-shelepen as a volunteer commentedThe tag has been added to make visible the issues on the sprint board.
Comment #13
tim.plunkettWhen running the test from #10 by itself (without the fix), it does not fail. This means that the test does not correctly expose the bug.
Working on this with @sugaroverflow at MWDS.
Comment #14
tim.plunkettAha! That was because a workaround for this issue was added yesterday in the inline blocks commit :)
#2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder
Comment #16
tim.plunkettSo the tests were fine after all.
Removing the workaround added in RevertOverridesForm makes the test fail, as expected.
Earlier our theory was that this was a bug with tempstore. And reloading the entity would "fix" it.
However the bug seems to be in our LayoutSectionItem implementation.
We consult the entity for the field, and then pass the field around. It itself can retrieve the entity.
Except that the entity it returns is not identical to the entity we are manipulating!
LayoutSectionItem already had a partial workaround for this:
__wakeup() is a magic method that runs when the object is unserialized (like from tempstore!)
The field losing track of the correct entity values happens much later than unserialized.
The solution we came up with was to move the resyncing from __wakeup directly to its internal
getEntity()
method.Comment #17
johnwebdev CreditAttribution: johnwebdev commentedTest coverage, simple solution and manual testing works as expected.
Comment #19
alexpottCommitted and pushed e3c750b08f to 8.7.x and 14e7fb44a0 to 8.6.x. Thanks!
Comment #23
tim.plunkettRetroactively tagging
Comment #24
tim.plunkettRetroactively tagging