Remembering that the rule will become a JavaScript json variable, windows takes exception to using backward slash in string. Why Linux allows is a mystery to me.
So the existing rule:
{fname:{presence: {message:\Required field missing: Please enter the First name}}, lname:{presence: {message:\Required field missing: Please enter the Last name}}}
Should end up as:
{fname:{presence: {message:‘Required field missing: Please enter the First name’}}, lname:{presence: {message:‘Required field missing: Please enter the Last name’}}}
Not knowing the full intent, i’ll leave to someone else to address.
This is odd since there are quotes in the entries in Administration->Lists->Page Validation entries.
Maybe there is either weird escaping or odd things happening in json_encode/decode
In my linux environment on the User edit gui, I am seeing: var collectvalidation = {rumple:{presence: {message:"Required field missing: Please enter the User Name"}}, stiltskin:{presence: {message:"Please enter the password"}}, fname:{presence: {message:"Required field missing: Please enter the First name"}}, lname:{presence: {message:"Required field missing: Please enter the Last name"}}};
Quotes aren’t the issue in windows it is the ''backslash. I think linux see it as to escape the next character and windows looks for a path. I’ll post the window output in a moment.
{fname:{presence: {message:\Required field missing: Please enter the First name\}}, lname:{presence: {message:\Required field missing: Please enter the Last name\}}}
wow, that’s just plain weird. Appears that quotes are getting converted to \ in windows there.
Here’s what I get in the outputted source for user_admin.php on linux (PHP 7.0 and PHP7.1; tested on the development demos):
var collectvalidation = {fname:{presence: {message:"Required field missing: Please enter the First name"}}, lname:{presence: {message:"Required field missing: Please enter the Last name"}}};
I’m betting it is a bug in the interpreter for windows. That or the interpreter simply is not seeing escape. I don’t get what we are escaping anyways. If it is to indicate the start of the string then wrong use case. Generally backslash in the string indicates a continuation of string or escape next special character. Notice there are not any quotes in page validation list params’ for users_admin edit…
{fname:{presence: {message:\Required field missing: Please enter the First name}}, lname:{presence: {message:\Required field missing: Please enter the Last name}}}
Even with quotes still doesn’t work on windows (only tested once with string quotes escaped with backslash). The only way it works is using quotes w/o backslash. Man i’m dyslexic today:)
There is no escaping that is happening to this variable, which is why it’s even more weird. What do you see if you do print_r on the $dataArray variable in above function before it is returned?
From validate L46 {fname:{presence: {message:\Required field missing: Please enter the First name}}, lname:{presence: {message:\Required field missing: Please enter the Last name}}}</code
From user_admin L67:
From php array: {fname:{presence: {message:\Required field missing: Please enter the First name}}, lname:{presence: {message:\Required field missing: Please enter the Last name}}}
and JS array browser where error happens:
/*
validation on the form with new client side validation (using validate.js).
this enable to add new rules for this form in the pageValidation list.
*/
var collectvalidation = {fname:{presence: {message:\Required field missing: Please enter the First name}}, lname:{presence: {message:\Required field missing: Please enter the Last name}}};
edit notice it is only first backslash and not terminating.
I’m almost convinced this is php bug on windows and like I say the rules in list should be setup as if a string and enclosed in quotes (same as if a static array in code). I know you worry about Matrix but I would change and move on.
I reality I don’t understand why we have a static list for individual forms. In the end once they are set, they will never change and is why validation rule should be set up with the form they effect. I would pull those static json rules and stick them where they are called in the form.
to clarify, if I go to Administration->Lists->Page Validation
then at row for user_admin#user_form, I have the following entry at Page Validation column:
{fname:{presence: {message:"Required field missing: Please enter the First name"}}, lname:{presence: {message:"Required field missing: Please enter the Last name"}}}
It sounds like this is different on windows and would then be an issue on the sql import (during install or upgrade) for these items.
This goes back to 4.2.2-5.0.0 upgrade. I know i’ve used user edit dialog since then. Good grief, I hate mystery such as this…This has had to be here for awhile and just now showing. Let’s just ignore it 'till someone else finds it…Okay:)
For now, will fix it in database.sql and upgrade script(and will ensure don’t have other unescaped quotes in database.sql). Since you are using php 7.1, kind of wonder if it may be from behavior of a newer mysql version (maybe why nobody has reported this).
Not if I delete this thread, ban everyone from using windows and just pretend this never happen:) Or, I could make absolutely sure this is not a fluke and upgrade on one of my other machine… I vote for option 1…