Closed (fixed)
Project:
Experience Builder
Component:
Page builder
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Jul 2024 at 01:28 UTC
Updated:
22 Aug 2024 at 09:29 UTC
Jump to comment: Most recent
Follow-up for #3450303: Implement undo/redo.
When we click on Undo/Redo buttons then we get a 500 error.It's failing on \ComponentElement::generateComponentTemplate(): Argument #4 ($context) must be of type array, null given, called in /var/www/html/web/core/lib/Drupal/Core/Render/Element/ComponentElement.php on line 65 .
Undo/redo behaves as expected.
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
hooroomooComment #3
hooroomooComment #5
utkarsh_33 commentedI think we are not completely block on Implement add section and add element buttons. We can still use Redo/Undo by adding elements by dragging from the menu bar.
Comment #6
utkarsh_33 commentedComment #8
utkarsh_33 commentedThis work is built on top of Implement add section and add element buttons because it's easier to write failing test showcasing that there's a problem with the Undo/Redo button.
I have added the test for undo only for now because i think both are facing the same problem , so fixing one's problem will automatically fox it for he other one.
So now describing the problem faced with this:-
1) When we click on the undo/redo button we get a 500 error.
2) The error prior to the latest 0.x was something like
he website encountered an unexpected error. Try again later.<br><br><em class=\"placeholder\">TypeError</em>: Drupal\\Core\\Render\\Element\\ComponentElement::generateComponentTemplate(): Argument #4 ($context) must be of type array, null given, called in /var/www/html/web/core/lib/Drupal/Core/Render/Element/ComponentElement.php on line 65.3) The error with the latest 0.x is coming out
The website encountered an unexpected error. Try again later.<br><br><em class=\"placeholder\">TypeError</em>: array_diff_key(): Argument #1 ($array) must be of type array, null given in <em class=\"placeholder\">array_diff_key()</em> (line <em class=\"placeholder\">36</em> of <em class=\"placeholder\">modules/contrib/experience_builder/src/Controller/SdcController.php</em>).I also checked the redux states are updated correctly and the model has the what it's supposed to have after clicking undo(one element less that the usual).So i majorly think it's a problem with the backend code(I might be wrong though).
Comment #9
utkarsh_33 commentedThe xb-general test fails can be ignored as it's failing on 0.x also.
Comment #10
wim leersThey're not: https://git.drupalcode.org/project/experience_builder/-/commit/f2641ed6a... → that's the latest
0.xcommit, and it's passing.Comment #11
utkarsh_33 commentedThe xb-general tests are now passing on this MR.The failing test are to show that existing problem with undo/redo functionality.
Comment #12
bnjmnmThere are 22 files being changed in the MR and the majority don't appear to be related at all to the reported error. Lets either clean that up or create a new MR.
Comment #13
wim leersPer @bnjmnm's review in #12.
Comment #14
wim leersThis work/test coverage can continue, but won't be mergeable until #3460952: Implement add button for top level item (section) lands.
Comment #15
wim leers#3460952: Implement add button for top level item (section) is in.
Comment #16
utkarsh_33 commentedMerged the latest changes from 0.x.The only tests that fails are expected to fail.Removing the tags as tests are already added.
Comment #17
wim leersI don't get
but I do get:
Possibly because the server-side code has evolved quite a bit.
If I then look at the request that gets sent after clicking Undo, it is:
Note how that second component
7637a2f8-2833-4de3-a4d3-368d413f66d6is listed inlayout, but does not have an entry inmodel! That's the bug! 🐛IOW: it makes sense that you get a 500 response (although the server should provide a better error message).
Then if I click "Undo" a second time, it sends:
… i.e. now
7637a2f8-2833-4de3-a4d3-368d413f66d6is gone fromlayouttoo, and you no longer get a 500 response. 👍Conclusion: this is caused by a bug on the client side. The undo/redo history state is incorrect.
Comment #18
wim leersI actually bet this is related to and perhaps has even the same root cause as #3452895: Undo/redo - user can undo the loading of the initial state.
Comment #19
wim leersComment #20
utkarsh_33 commentedI was able to fix the issue with the Undo/Redo and i also expanded the test coverage to test both undo and redo button and it works now.Marking it to needs review.
Comment #21
utkarsh_33 commentedComment #22
utkarsh_33 commentedI found a small regression issue Undo/redo - user can undo the loading of the initial state (regression). related to the problem being solved in this MR.I think it makes more sense to fix it in this issue only.
Comment #24
utkarsh_33 commentedSaving credits for @syeda-farheen as Undo/redo - user can undo the loading of the initial state (regression) issue is solved here only.
Comment #27
jessebaker commented