-
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
ScriptManager.Evaluate method does not cast variables #16856
Comments
Sounds like yet another STJ interop problem, I guess behavior could have changed after switch from Newtonsoft. Jint could also have some regression if no test coverage exists for this kind of thing. |
This could be due to the way |
Are you saying that in version 2.0.2, we can use the data returned from the deserializeRequestData method without any casting? I'm getting all kinds of errors in my tests. I think the problem is not with the deserializeRequestData method, but with the Json Serializer. |
Not sure what has changed here in 2.0, but I think the issue is that |
Given that casting was not previously required in the script, I'm hesitant to state definitively that casting is now mandatory post-2.0. This could potentially result in a negative user experience. |
I agree that this seems to be a regression. |
To maintain compatibility with my existing scripts and minimize the need for casting, I've developed a custom method. This method implicitly converts non-string data types to strings to prevent runtime errors. However, explicit casting of non-string data types remains essential for correct data handling.
The ideal usage should be as follows: I have come to the conclusion that we should cast it in every way.
|
I think we should keep this opened. |
I think we need a Jint type handler for StringValues which would return a string or a string[] based on the number of values. |
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. |
Describe the bug
In versions 1.8.X, I was able to record content with my javascript code without any problems using the scriptManager.Evaluate method. In my tests on 2.0.2, I needed to cast the variables I read using the deserializeRequestData() method, it worked without the need for a previous cast operation. When I did not cast, I got a Json.Serialization error.
Orchard Core version
2.0.2
This used to work with 1.8.x, so it's a regression
To Reproduce
To simulate this error, I created a workflow and I am sending form-data to this workflow via postman, I am trying to read the values with the deserializeRequestData method in the script task and create new content.
Workflow-Jint-Test.zip
Expected behavior
I expect it to work with this js;
After the 2.x upgrade, it only works properly as I cast it below.
Is this an expected situation? Should I add cast functions to all my codes like this after the upgrade?
The text was updated successfully, but these errors were encountered: