Overview
When you send a PATCH request to the experience_builder.api.config.patch route, it (via experience_builder_entity_update()) deletes the version that's in auto-save storage, which is correct since that's now outdated. However, sometimes what we want instead is to apply the same set of changes to both the published entity and to the auto-saved one. For example, in #3513147: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version, we want to set status=1 to both the published js_component and the auto-saved one, while neither deleting the auto-saved one nor publishing the other changes that are in the auto-saved one. The reason we want that is setting status=1 needs to trigger the creation of the corresponding component entity, but it should only do that when the entity is saved for real.
A way to think of this is: we want to apply a "hot fix" to both the production branch (the published entity) and the development branch (the auto-saved draft).
Proposed resolution
- Proposal by @wimleers
-
See #4 + #5.
Implemented in https://git.drupalcode.org/project/experience_builder/-/merge_requests/937 and passing tests.
- Original proposal by @effulgentsia
-
We already have these two routes:
experience_builder.api.config.patchexperience_builder.api.config.auto-save.patch
Create a 3rd route, (what's a good name:
experience_builder.api.config.published-and-auto-save.patch?experience_builder.api.config.hotfix.patch?), that applies the PATCH body to both.
User interface changes
Issue fork experience_builder-3519634
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
Comment #2
effulgentsia commentedComment #3
effulgentsia commentedComment #4
wim leersHow do we know which config entity properties this is safe to do for?
Would it be okay to start with only
status? 🙏Helpful metaphor 👍
Why? Why not:
Comment #5
wim leersCrafting a draft MR.
Another reason to do what I proposed in #4 is to prevent auto-saves being wiped when updating config through some other way (e.g. CLI upload tool or perhaps even config sync): imagine that the label of a
JavaScriptComponentconfig entity is modified by the config sync, then you don't want to lose your auto-saved changes to the actual JS code.Comment #7
wim leersOutline of MR pushed.
Comment #8
wim leersWhat I'm proposing is essentially a subset of #3492059: [META] Conflict-free concurrent editing.
Comment #9
wim leersThis blocks #3513147: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version.
Comment #11
wim leersComment #12
wim leersConfirmed by @hooroomoo at #3513147-13: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version that this fixes the problem. (But there's another bug they surface there. So we can't merge this until @hooroomoo clarifies at #3513147-14: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version how to reproduce that bug.)
Needs sign-off from an auto-save maintainer. @larowlan is out, so @tedbow, over to you!
Comment #14
tedbowLooks good! will merge on green tests
Comment #15
wim leersQuoting #12:
Comment #16
hooroomooSo just to preface, all my testing has been with sending PATCH requests to
/xb/api/config/js_component/${id}, not the auto-save because that's what's currently in the code.Could you confirm if client side PATCH requests to change the status or the label should still be sent to
/xb/api/config/js_component/${id}or does it need to change to send it to/xb.api/config/auto-save/js_component/${id}?1. WITHOUT frontend change
This issue I was seeing on this MR (with no frontend changes) turned out to also exist in 0.x. The bug (let's call this Bug #1) is
Since the bug also exists in 0.x, that means this MR is not the cause of it.
2.) WITH frontend change to PATCH request to only send necessary changes.(Currently in 0.x, PATCH requests are still sending the entire component )
/sites/default/files/astro-islandnothing is generated from your newly created code componentThis behavior exists on both 0.x and this MR, WITH the frontend change to the PATCH request of only sending wanted changes.
----------------------------------------
So my conclusion: I don't think merging in this MR will cause any regressions that don't already exist in 0.x, However, I think we should open a ticket for the frontend updating its PATCH requests to only send wanted changes and also with help from the backend to figure out bug #2 - why aren't the compiled files being generated when the PATCH request body changes?
Comment #17
wim leersThe answer depends:
/xb/api/config/auto-save/js_component/…/xb/api/config/js_component/…Comment #18
wim leers@tedbow If you have time, could you please investigate #16?
Comment #19
tedbowInvestigating
Comment #20
tedbowInvestigated #16.1 with @hooroomoo , created a new issue #3521072: Auto-saved Javascript Components CSS changes do not work with CSS aggregation,
Comment #21
tedbowFor #16.2 I think we figured out that it is NOT an issue with the current MR.
which makes sense because in 0.x we would be deleting the auto-saved entry of the component if you just sent the status, while in 0.x we would just updating the status in the auto-save entry
@hooroomoo can you confirm?
Comment #22
hooroomooI think the issue i was seeing in 16.2 had to do with my css aggregation being on or something else weird because I tested it again with css aggregation OFF, and I'm able to correctly see the autosaved component in my page preview. Also renders correctly after publishing.
I think this MR is good to go. I added the frontend changes to change the PATCH request to only send wanted changes and it works as expected.
This MR should fix both:
#3513147: Using actions from the contextual menu from the sidebar list overrides code component with its latest non-autosaved version #3520698: Cannot add component to the component library using the contextual menu
Comment #23
hooroomooComment #24
effulgentsia commentedThis looks good to me, but there's a failing E2E test that looks like it could be related to this MR, not just a flaky test.
Comment #25
hooroomooI've seen the same assertion fail on different MRs as well as on 0.x so I think it might just be the flaky test and there was an issue filed for it #3520830: Cypress test publish-validation is flaky.
The fail is definitely unrelated to the frontend change. But maybe @tedbow could confirm if the fail is unrelated to the backend changes
Comment #26
hooroomooexperience_builder.auto_save.inc doesn't exist in 0.x anymore since #3517636: Move to OO hooks now we require 11.x got in so this needs a rebase
Comment #27
hooroomooComment #28
tedbowre #24 and #25 I ran the failing tests locally on 0.x and the MR branch.
publish-validation.cy.jsconsistently passes for me locally on both branchescomponent-operations.cy.jsconsistently passes for me on 0.x and consistently fails on the MR branch 😢. I haven't looked into why yet@hooroomoo have you run the tests locally? Would be good to double check if someone else gets the same result
Comment #29
tedbowComment #30
hooroomooAssigning back to @tedbow to fix the merge conflicts with 0.x and hoping for a successful test run post-rebase since some test improvements got into 0.x this morning
Comment #31
wim leersI'll tackle that since I worked on #3517636: Move to OO hooks now we require 11.x.
Comment #32
wim leersThe e2e test failures have been fixed in #3521730: Make the current crop of fussy tests less difficult.
Comment #33
wim leersMerging given the approvals by @hooroomoo and @tedbow — thanks both of you for the intense collaboration on this issue cluster! 😄🙏
Comment #36
effulgentsia commented