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

Discussion in 'Standard Support' started by shawnmcginn, Aug 13, 2018.

  1. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Standard
    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: Aug 13, 2018
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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
     
  4. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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)


    upload_2018-8-14_14-8-36.png
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Try unpublishing that validation, see if the error still happens.

    -- hugh
     
  6. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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.
     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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.
     
  8. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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.
     
  9. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Which site?

    If I login, is it live? Can I enable debug mode, etc?

    -- hugh
     
  10. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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.
     
  11. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Which form / element?

    -- hugh
     
  12. shawnmcginn

    shawnmcginn Member

    Level: Standard
    I put the info in the mysites notes section.. can you see those notes or are they strictly for me?
     
  13. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Ah, sorry, I hadn't looked there. OK, checking on it now.

    -- hugh
     
  14. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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
     
  15. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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
     
  16. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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
     
  17. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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
     
  18. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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 (Text):

    class myStuff {
       public static function validateSomething($data) {
          // do some stuff
          return true;
       }
    }
     
    Then in your condition, do ...

    Code (Text):

    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 (Text):

    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 (Text):

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

    shawnmcginn Member

    Level: Standard
    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.
     
  20. shawnmcginn

    shawnmcginn Member

    Level: Standard
    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.
     

Share This Page