• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

0 - syntax error, unexpected '==' (T_IS_EQUAL)

I'm migrating a site to PHP 7 (J! 3.8.11, Fabrik 3.8.1) and I've run into this problem when I try to submit my form (multipage) I'm getting the following:

syntax error, unexpected '==' (T_IS_EQUAL)

Call stack
#
Function Location
1 () JROOT/components/com_fabrik/models/validation_rule.php(157) : eval()'d code:1
2 PlgFabrik_Validationrule->shouldValidate() JROOT/components/com_fabrik/models/form.php:2361
3 FabrikFEModelForm->validate() JROOT/components/com_fabrik/controllers/form.php:298
4 FabrikControllerForm->process() JROOT/libraries/src/MVC/Controller/BaseController.php:710
5 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_fabrik/fabrik.php:181
6 require_once() JROOT/libraries/src/Component/ComponentHelper.php:382
7 Joomla\CMS\Component\ComponentHelper::executeComponent() JROOT/libraries/src/Component/ComponentHelper.php:357
8 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:194
9 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:233
10 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:195
11 Joomla\CMS\Application\CMSApplication->execute() JROOT/index.php:49

I found an article in the forum that mentions potential issues with custom validations but after seeing this I went back to confirm if validations are working at all. On my first validation I found it's throwing errors such as this:

POST https://mysite.com/form/3/ 500 (Internal Server Error)
send @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:5398
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
send @ mootools-more-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:3677
doElementValidation @ form.js:1089
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
(anonymous) @ form.js:1010
dispatch @ jquery.js?c107c4e8acdfd927be0d9360c7658435:5226
elemData.handle @ jquery.js?c107c4e8acdfd927be0d9360c7658435:4878

Uncaught SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object._completeValidaton (form.js:1100)
at Object.wrapper.extend.$owner (mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312)
at Object.<anonymous> (form.js:1087)
at Object.<anonymous> (mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1432)
at Array.forEach (<anonymous>)
at Function.forEach (mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:218)
at Array.each (mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:335)
at Object.fireEvent (mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1430)
at Object.wrapper.extend.$owner (mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312)
_completeValidaton @ form.js:1100
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
(anonymous) @ form.js:1087
(anonymous) @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1432
(anonymous) @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:218
each @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:335
fireEvent @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1430
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
onFailure @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:5296
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
failure @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:5292
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
onStateChange @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:5266
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
XMLHttpRequest.send (async)
send @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:5398
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
send @ mootools-more-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:3677
doElementValidation @ form.js:1089
wrapper.extend.$owner @ mootools-core-uncompressed.js?c107c4e8acdfd927be0d9360c7658435:1312
(anonymous) @ form.js:1010
dispatch @ jquery.js?c107c4e8acdfd927be0d9360c7658435:5226
elemData.handle @ jquery.js?c107c4e8acdfd927be0d9360c7658435:4878

Following the upgrade from J! 3.8.6 to J! 3.8.11 I found there were no required Fabrik upgrades. Any thoughts on this? This mootools piece looks to be joomla core so I can't imagine I need to upgrade it. Let me know if you need more detail in order to debug this.

Thanks!
Shawn
 
It seems to be related to some custom code in a validation condition. So check your validation conditions.

"Uncaught SyntaxError: Unexpected token..." is usually coming from an error message thrown at a place where a JSON string is expected, so I assume in this case it's the error message "Caught exception on eval in validation condition : ..."
You can find the message in your browser console in the response in "Network" tab.

BTW:
validation_rule.php(157) : eval()'d code:1
line 157 doesn't match the current 3.8.1 code.
Did you update all your Fabrik plugins to 3.8.1?
 
Last edited:
Judging by the error (syntax error, unexpected '==' (T_IS_EQUAL)), it's probably the use of a placeholder without quotes, like ...

PHP:
if ({yourtable___yourelement} == 'foo') {
   /// do something
}

... which, if that placeholder is empty, would try and run the code as ...

PHP:
if ( == 'foo') {

So look for something like that, and if you find it, put quotes round the placeholder ...

PHP:
if ('{yourtable___yourelement}' == 'foo') {

... that way, if the placeholder is empty, it'll run as ...

PHP:
if ('' == 'foo') {

... which is syntactically (and logically) correct.

-- hugh
 
I tried removing any conditional parameters from my validation so it's completely vanilla and I get this in dev tools. I understand the explanation above, that may be an issue in one of my lower validations but this is a basic notempty validation (see screenshot below)

POST https://mysite/en/applicant-list-en/form/3/ 500 (Internal Server Error)
send @ mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:4127
e.extend.$owner @ mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:905
send @ mootools-more.js?4579b7abdf24749ccab7d0130d78b295:248
doElementValidation @ form.js:3
e.extend.$owner @ mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:905
(anonymous) @ form.js:3
dispatch @ jquery.min.js?4579b7abdf24749ccab7d0130d78b295:3
r.handle @ jquery.min.js?4579b7abdf24749ccab7d0130d78b295:3
VM5916:1 Uncaught SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object._completeValidaton (form.js:3)
at Object.e.extend.$owner (mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:905)
at Object.<anonymous> (form.js:3)
at Object.<anonymous> (mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:988)
at Array.forEach (<anonymous>)
at Function.forEach (mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:151)
at Array.each (mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:223)
at Object.fireEvent (mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:987)
at Object.e.extend.$owner (mootools-core.js?4579b7abdf24749ccab7d0130d78b295:formatted:905)


View attachment 17463
 
If I unpublish I don't get an error, it simply does not run any js for validation. And I should also mention the form does use ajax validations.
 
OK, try deleting it, saving the element, and add it back. Also make sure you specify an error message. And that the "Condition" is completely empty - no spaces.
 
Same issue, I deleted the validation, tested without it first, no error on validation, added it back with an error message and didn't touch condition and I get the same error.
 
It's the last one in my list with 'pair' in the name - I just updated it for you let me know if you have any issues. It is live but it's temporary as it's a migration effort Im' working on so once I work out all the kinks I can do a full migration.
 
OK, even with that validation unpublished, the form still errors out - I've turned off AJAX validation so I can see the result of submitting it.

Do you have any other validations with your code in them, like in conditions, etc?

Unfortunately I can't get it to give me an error message, I just get a white screen with "500" (internal server error).

-- hugh
 
I have a lot of validations with code in the conditions yes. I too am getting the 500 error when I try the backend with blank page. Try logging into the form via the frontend. It's at mysite.com/en/login
 
When I submit through the frontend I get this:



0 - syntax error, unexpected '==' (T_IS_EQUAL)
You may not be able to visit this page because of:

  1. an out-of-date bookmark/favourite
  2. a search engine that has an out-of-date listing for this site
  3. a mistyped address
  4. you have no access to this page
  5. The requested resource was not found.
  6. An error has occurred while processing your request.
Please try one of the following pages:

If difficulties persist, please contact the System Administrator of this site and report the error below.

syntax error, unexpected '==' (T_IS_EQUAL)



Call stack
#
Function Location
1 () JROOT/components/com_fabrik/models/validation_rule.php(157) : eval()'d code:1
2 PlgFabrik_Validationrule->shouldValidate() JROOT/components/com_fabrik/models/form.php:2361
3 FabrikFEModelForm->validate() JROOT/components/com_fabrik/controllers/form.php:298
4 FabrikControllerForm->process() JROOT/libraries/src/MVC/Controller/BaseController.php:710
5 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_fabrik/fabrik.php:181
6 require_once() JROOT/libraries/src/Component/ComponentHelper.php:382
7 Joomla\CMS\Component\ComponentHelper::executeComponent() JROOT/libraries/src/Component/ComponentHelper.php:357
8 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:194
9 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:233
10 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:195
11 Joomla\CMS\Application\CMSApplication->execute() JROOT/index.php:49
 
Yup, that's another one with a problem on your validation condition.

So it's definitely a bug in your condition code. When I looked at that other element, you were doing a "return require /path/to/some_script.php", but of course I can't see the content of that file.

Are you doing the same thing in those other validations, requiring some code in a file?

If so, what is that code?

-- hugh
 
And, btw, rather than doing a "return require", which presumably includes a file that just has some inline PHP that ends with "return true;" (or whatever), the much better approach is to create you own static class, with functions in it, and then call those functions ...

Code:
class myStuff {
   public static function validateSomething($data) {
      // do some stuff
      return true;
   }
}

Then in your condition, do ...

Code:
require_once JPATH_ROOT . '/relative/path/to/yourfile.php';
return myStuff::validateSomething($data);

Then you can add different function in that one file, and just call whichever one you happen to need for a given validation.

Oh, and ... if you are trying to use Fabrik {table___element} placeholders in that included file, that won't work. You'll have to access $formModel->formData[] directly. let me know if that's what you are doing, and I'll give you some more hints. But in the class example ...

Code:
class myStuff {
   public static function validateSomething($data, $formModel) {
      // return true if some_other_element == 1
      return $formModel->formData['mytable___some_other_element'] == '1';
   }
}

Then in your condition, do ...

Code:
require_once JPATH_ROOT . '/relative/path/to/yourfile.php';
return myStuff::validateSomething($data, $formModel);

-- hugh
 
It's a bit of a long story, I had to control the validations based on a users' acl and rather than put the code in every single element that requires not-empty I use the include and code it there.. also, I have some logging that I run from there. So for the purposes of your testing I just commented out all the code in the script but as you'll see it still produces the same error.
 
I'll take your recommendation and update my custom validation but for now I've basically removed the work it does with conditional acls and I still have the same issue. Note as well this works fine on php5.6 it's just on this new server I'm running php7, that's really the only difference.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top