Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo appears to be breaking Fred #137

Open
matdave opened this issue Oct 23, 2024 · 3 comments · May be fixed by #138
Open

Undo appears to be breaking Fred #137

matdave opened this issue Oct 23, 2024 · 3 comments · May be fixed by #138

Comments

@matdave
Copy link

matdave commented Oct 23, 2024

It appears that VersionX is storing the Resource properties data in a strange way. When clicking the "undo" it is modifying the Fred object into a way where Fred can no longer read it.

e.g. Before undo:

"fred":{"data":{"content":[{"widget":"93a11a9c-de0b-42fb-a2ad-9d4ca47f3a1b","values":[],"pluginsData":[],"settings":[],"children":[],"elId":"fred_e6bce7c_6oermhdfaxh"},{"widget":"88fe082e-8270-4a30-9f38-9634ce0cbff9","values":{"test":{"_raw":{"_value":"This is a test<br>"}},"text":{"_raw":{"_value":"<p><a href=\"\/blog\/\" data-fred-link-type=\"page\" data-fred-link-page=\"2\">Test tiny mce test<\/a><\/p>\n<p><img src=\"\/assets\/fred\/modx.png\" alt=\"modx.png\"><\/p>"}}},"pluginsData":[],"settings":{"test":""},"children":[],"elId":"fred_0f00a08_sx8xepm5hgk"}],"fingerprint":"ced09ab03db6eab390a937ddb29703e393c0491c"},"plugins":[]}

After undo:

"fred":{"data":{"content":":{0:{widget:93a11a9c-de0b-42fb-a2ad-9d4ca47f3a1b,values:{},pluginsData:{},settings:{},children:{},elId:fred_e6bce7c_6oermhdfaxh},1:{widget:88fe082e-8270-4a30-9f38-9634ce0cbff9,values:{test:{_raw:{_value:This is a test<br>}},text:{_raw:{_value:<p><a href=\"\/blog\/\" data-fred-link-type=\"page\" data-fred-link-page=\"2\">Test tiny mce test<\/a><\/p>\n<p><img src=\"\/assets\/fred\/modx.png\" alt=\"modx.png\"><\/p>}}},pluginsData:{},settings:{},children:{},elId:fred_0f00a08_sx8xepm5hgk}}","fingerprint":"e6bcb6087c9d9a4f384baee7ed034f2e71c1905c"}

Notice how it converts the "content" to a giant string.

@matdave
Copy link
Author

matdave commented Oct 23, 2024

For context, the "Revert all changes" seems to work fine. It is just the "undo" button that breaks things.

@muzzwood
Copy link
Contributor

Thanks @matdave. It looks like something's going awry when the array is being flattened during delta creation.
IIRC that utility was kept from the old version. I wonder if we can't just straight up use json_encode()...

The only downside I can think of off the top of my head is there might be some data in properties that is intended to be kept as json and others that isn't (when decoding). I'll investigate...

@muzzwood
Copy link
Contributor

muzzwood commented Nov 1, 2024

Hi @matdave , would you be able to give this PR a try and see if it solves the issue?
#138

Note that you'll need to manually add these two columns to the versionx_delta_field table in order to test it.

<!--
Keep track of the before and after value types so reverting doesn't decode an intended json string,
or cast an int as a string etc. Empty value means it's a string.
-->
<field key="before_type" dbtype="varchar" precision="7" phptype="string" null="false" default="" />
<field key="after_type" dbtype="varchar" precision="7" phptype="string" null="false" default="" />

@muzzwood muzzwood linked a pull request Nov 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants