-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
ContentPartFieldDefinition Settings.ToObject deserializes to empty object #16764
Comments
Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. On what happens next, see the docs. If you like Orchard Core, please star our repo and join our community channels. |
I can submit a PR to fix this for deserializing settings in the DisplayDriver classes. But I need guidance on if I should also change to use |
@davidpuplava I think using If that indeed fixes the issue, you may also want to fix it here |
Yes, at least in the TextFieldSettings display driver it fixes it. I'll confirm in the other places that there is a problem before I fix it. Thank you @MikeAlhayek. |
We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues). This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here. |
Oh no, how did we miss this. It's breaking 2.0 and should be fixed asap. |
I should have the PR ready here shortly, in the next couple of hours. I wrote some unit tests to check each field type. |
Waiting for your PR |
PR submitted: #16774 |
Describe the bug
Content Part Fields Settings are not showing on the edit screen because they are NOT deserialized successfully.
Orchard Core version
Commit: f9fb26a
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected to see the "Test Hint" value in the "Hint" text field
Logs and screenshots
Here is a screen capture of the issue (this GIF also shows a potential solution).
![oc-textfield-settings-bug](https://private-user-images.githubusercontent.com/5144137/369039596-8837be8b-5999-4981-a689-7922ced11dac.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3NTI5MjAsIm5iZiI6MTczOTc1MjYyMCwicGF0aCI6Ii81MTQ0MTM3LzM2OTAzOTU5Ni04ODM3YmU4Yi01OTk5LTQ5ODEtYTY4OS03OTIyY2VkMTFkYWMuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTdUMDAzNzAwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjYxZjJmOGQxN2IzMmQxZjczNWRjN2JhMTM5N2Y4NGE3MTRiODYwODhjNmY4NTI5NDZhZDRiODA4MWJkYzJlNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.zwWN1zERbmxJ5tytqvsBLcEyxGaQLXTo35PIQV5PNHY)
Analysis
Looks to be related to the removal of Newtonsoft. The
TextFieldSettingsDriver.cs
file changed to the following block of code to deserialize the text field settings:This particular line of code returns an empty TextFieldSettings object because the Settings property is an array of 2 JsonObjects rather than a TextFieldSettings object directly.
![image](https://private-user-images.githubusercontent.com/5144137/369043480-7aae250a-4b5b-4b02-a5fe-9e2a51a91af9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3NTI5MjAsIm5iZiI6MTczOTc1MjYyMCwicGF0aCI6Ii81MTQ0MTM3LzM2OTA0MzQ4MC03YWFlMjUwYS00YjViLTRiMDItYTVmZS05ZTJhNTFhOTFhZjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTdUMDAzNzAwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjM5ZDU3YjQ5NzY3OThiYTU5Mjg3NGVmODdlNjFlNGEzM2NkODg4ZmQ1OWJhYzQ0MzkyM2M4NjJlNDQxNWZkZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.veXPqxArCRoO7YMRLa0rGUmOCfwwR2ZR3yRk4Y4d7ko)
Possible Solutions
Inspecting the
Settings
property on theContentDefinition
type has a comment that says not to access directly and instead use the GetSettings method.Changing to use
GetSettings
method does appear to correctly deserialize the settings object.Other Considerations
This looks to affect other field settings such as BooleanFieldSettings. Searching the code base, I see 20 instances of
...Settings.ToObject<...
which likely need to be tested and fixed as well.Most importantly there are Migrations in
OrchardCore.ContentManagement\Records
that look to access the Settings in the same way. I'm not sure of the implications of changing that migration to useGetSettings
.The text was updated successfully, but these errors were encountered: