After Upgrading Fabrik and Joomla to Latest Release Getting Error '0' syntax error, unexpected

eugenecjr

Member
Fabrik as been upgraded to V3.7 as well as Joomla to 3.74. Site is using PHP 7.1. This appears to only affect forms that are using groups as I have two forms that use groups that have been impacted by this issue.

On of the forms is getting a syntax error of:
syntax error, unexpected '>'

The other form is getting an error of:
syntax error, unexpected '

Both indicate:

0 Error

Any assistance in resolving this error would be appreciated. Please let me know if you need additional information.

-Eugene
 
That is correct the site is for Incredibly Designed Inc. The forms that I am having issues with require you to login using the information supplied in your ?mysites?.

Once logged in the two forms that are presenting the issues are Fruit Ordering under Employee Access and Currency Exchange under Operation Manger Access ?> Currency.

Let me know if you have any additional questions.

-Eugene


Sent from my iPhone using Tapatalk
 
I'll need to bump up error reporting levels on your site for a minute, so you'll need to make that account a super admin.

-- hugh
 
OK, the problem(s) are in your calcs. I fixed the first couple on the Fruit form, but as you have dozens of them, you'll need to go through and fix them.

Basic issue is, you have to quote placeholders if they can ever be empty. Which, when creating a new form, they often will be. Otherwise, you end up with invalid PHP syntax. Placeholders are not like PHP variables. We (Fabrik) replace those placeholders with the value of the element BEFORE we hand you code fragment to PHP to evaluate. So consider this code:

Code:
if ({yourtable___foo} > 1) {
   ... do something
}

If that elements has a value, say 3, the resulting code handed to PHP is ...

Code:
if (3 > 1) {

.... which is fine. But if it is empty ...

Code:
if (> 1) {

... which is a syntax error, "unexpected '>'".

So ... you need to quote the values ....

Code:
if ('{yourtable___foo}' > 1) {

... so if they are empty, the code handed to PHP is still valid ...

Code:
if ('' > 1) {

... which is valid. Even better, cast your quoted placeholder to the data type you are expecting, so if (say) 'foo' is a quanity (so it's a whole integer) ...

Code:
if ((int)'{yourtable___foo}' > 1) {

if it's a decimal value ('3.95'), cast it to (float). Although be aware of the potential issues with floating point arithmetic in PHP, and round() your results appropriately.

So ... you need to go through all of your calcs, and anywhere an empty placeholder would result in invalid syntax, quote (and preferable cast) it.

http://fabrikar.com/forums/index.php?wiki/calculation-element/&noRedirect=1

-- hugh
 
I will take a look at this as soon as I get back to my computer. If at all possible do you have a specific one that you can caption as an example. This will assure that I am looking at the right thing. Then I will take that and replicate through the various forms.


Sent from my iPhone using Tapatalk
 
I've done 'kale_needed' and 'cantaloupe_needed', element IDs 70 and 71. but it's not hard. Anywhere you have {tablename___elementname}, put single quotes round it, '{tablename___elementname}'.

BTW, there's quite a few potential issues with the way you are doing all these calcs. In particular, note in the wiki where it talks about not using placeholders for other calc elements, in a calc element, because there's no guarrantee about what order they are going to get evaluated in, so you can wind up situations where element A relies on the result of element B, but element A gets run first. Sometimes you get lucky, and the order of evaluation works out right. Sometimes you don't.

-- hugh
 
Thanks I see what was done and although I felt it was as simple as it looked hate to assume otherwise and create mess. Also better to ask then to just assume.

With that said it is interesting that you mention the potential issues. I will take a look at the wiki. I always assume there are better ways of doing things based on my knowledge. I am interested in knowing how I can doing things better. If I have questions I will let you know.


Sent from my iPhone using Tapatalk
 
Also better to ask then to just assume.

Oh absolutely. One of my mottos is "the only stupid questions are the ones you don't ask". And I wasn't trying to be deprecating in any way, just reassuring you that it's not rocket science. I know code can be daunting when you aren't a coder.

While you are going through the calcs, I'd suggest making a note of any which use placeholders for other calcs in them.

-- hugh
 
I got all of the calculations updated and the form now loads. I am now presented with another error I did not have before the update. When the form loads a store is selected and that has the from do a Auto fill of the stores email address. When I go to take a look at the element that is used to select the store, which is a databasejoin element it seems to have issues loading information on the data tab.
 
Looks like you have some kind of 3rd party system plugin which is wrapping <body> tags around AJAX responses. I'm looking for the culprit now.

-- hugh
 
I've been poking around for half an hour, but I can't figure out which of your 3rd party plugins is causing the problem.

Something is interfering with the response to our AJAX call that populates the dropdown of tables (where our Javascript makes an AJAX call to the server to get the data). It should return a simple JSON array of table names, like:

Code:
["","xxx_art_adminer_setting","xxx_assets","xxx_associations","etc"]

... but one of your plugins is replacing HTML entities (so " become &quote and wrapping HTML tags around it:

Code:
<html><body><p>[&quot;&quot;,&quot;xxx_art_adminer_setting&quot;,&quot;xxx_assets&quot;,&quot;xxx_associations&quot;]</p></body></html>

Our Javascript is expecting the JSON response, and feeds it to JSON.parse() ... but because it's got that HTML tag, that's where the "Unexpected <" comes from.

I've removed about a hundred table names, to make the text clearer.

So ... you need to figure out which of your plugins is doing that. Usually when this happens, it's something to do with templating, and/or it's a system plugin that has something to do with formatting your site layout. So I suspect it's something to do with JSN. But I was unable to disable the "JSN Framework" plugin, because then the page loads break with an error in some other JSN plugin.

-- hugh
 
Last edited:
I finally managed to turn all the JSN stuff off, which didn't help. But there's some plugin running, probably on the onAfterRender hook, wrapping our response in those tags and running it through htmlspecialchars().

Sent from my HTC6545LVW using Tapatalk
 
I have also been playing around with it a little bit. With that not being the issue I am assuming that it is a matter is just working through the plugins to see which one is causing the issue. I have a thought as to if the Easy Profile might have something to do with it.
 
I disabled all of the Easy Profile Plugins some of which are type jsn but that did not make a difference. Although my knowledge has me limited to testing via the user interface. Looking at the generated page code is likely to be a little more specific as to if there were any actual changes.
 
Yeah, I don't really have anything useful to contribute. Usually I can track these things down by just going through the non-Joomla (3rd party) 'system' plugins, turning them off one by one, till the problem goes away. I did that, but no luck. Which means it could be in any of your 3rd party plugins, not just the 'system' ones. And you have a LOT of extensions and plugins. I can't even see your whole Components menu, it overflows my browser window, even on a 17" hi-res laptop.

The only way I could help at this point would be to install an Akeeba clone of your site here, and step through the code in a debugger. But that's something we have to charge a fee for.

I've run across this sort of issue before, and it's always a plugin which handles modifying layouts, like templating, which is taking the output from other extensions, and modifying it. In this case, they haven't wrapped a test round their code to ONLY do it for "format=html". The AJAX call we are making to get that table list is "format=raw".

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top