DMXzone Server Connect Support Product Page

Solved

Bug in latest App Connect update - problems with URL parameters.

Reported 22 Mar 2017 10:42:29
1
has this problem
22 Mar 2017 10:42:29 Tom Dupre posted:
I updated to the latest version of App Connect this morning and the search facility of a site I'm working on stopped working. I have tracked down the problem; hopefully this can be fixed in the next update.

I have a search form which can take search several parameters, eg:
?search=gould+birds

Before the update, the MySQL query which App Connect generated included:
WHERE `searchfield` LIKE CONCAT('%', 'gould', '%') ESCAPE '!' AND `searchfield` LIKE CONCAT('%', 'birds', '%') ESCAPE '!' ORDER BY `sort_author` ASC LIMIT 15
.. which works as I want.

After the update:
WHERE `searchfield` LIKE CONCAT('%', 'gould+birds', '%') ESCAPE '!' ORDER BY `sort_author` ASC LIMIT 15
.. which of course is not what I want - it's unlikely that any results will be returned.

I think the problem is caused by changing this line in dmxAppConnect.js :
return escape(t) + "=" + escape(this.props.params[t])
to
return encodeURIComponent(t) + "=" + encodeURIComponent(this.props.params[t])
in about line 1727 (depending on how you view the code)

It was fortunate that I had a copy of the old file to hand, but if not, is there anywhere were previous versions can be downloaded in case of problems like this?

Thanks.

Replies

Replied 22 Mar 2017 12:13:02
22 Mar 2017 12:13:02 Patrick Woldberg replied:
How do you split the parameter value on the server-side and what was your input on the client-side?

A plus sign in the query string is decoded as a space character, escape didn't encode a plus sign, but encodeURIComponent encodes it as %2B which it should be. Some browsers would encode a space character as plus sign, that is why it should be encoded.
Replied 22 Mar 2017 12:28:44
22 Mar 2017 12:28:44 Tom Dupre replied:
The input in this example was 'gould birds'. I agree it should be encoded - and it is: it appears in the address bar like this:
?search=gould+birds
The problem - which has only arisen since the last update of App Connect - is that the query generated by App Connect treats the '+' separated query string as a single search parameter, ie as 'gould+birds', not as 'gould' and 'birds'.

To get round the limited options in Server Connect (no nested queries etc.), I am using several parameters like this:
{{$_GET.search.split(" " )[0]}}
.. so the query string is split up into separate search terms. Basically, I need a multi-field, multi-keyword search - so the user enters a string which is split up and creates multiple AND statements. This works (or worked) fine, except I had to use a trigger in the database to merge several fields which I want to search in. Hopefully there will be a better solution once the promised 'advanced' query features of Server Connect are available. In the meantime this was a solution - and still is if I modify dmxAppConnect.js (which would be a nuisance to maintain).
Replied 22 Mar 2017 14:37:11
22 Mar 2017 14:37:11 Patrick Woldberg replied:
Are you passing the search query to page with App Connect and then pass the parameter to the Server Connect action?

I found out there was an other bug in the App Connect, it didn't do any decoding of the url parameters, the encoding was fixed in the last update, but decoding not. Will have that fixed for the next update.
Replied 22 Mar 2017 16:01:16
22 Mar 2017 16:01:16 Tom Dupre replied:
I'm adding the filters - {{$_GET.search.split(" " )[0]}} , [2], [3] etc. - via Database Source Query Builder and then including:
dmx-param:search="query.search"
.. within <dmx-serverconnect> </dmx-serverconnect>
On this I also a form with:
<input name="search" type="text" class="form-control" id="search" placeholder="enter up to x search terms">

This worked fine previously - resulting in the SQL query I included in my first message: a string of submitted keywords is split up and included in a series of AND clauses, apparently across multiple fields (but actually across single, concatenated field - which is not ideal).

I hope the behaviour will be fixed in the next update. If the change fixed something else, I would be happy to use a different approach if there is one.
Replied 22 Mar 2017 18:27:49
22 Mar 2017 18:27:49 Tom Dupre replied:
I didn't read your last reply very carefully and didn't realise you were one of the extension developers - I assumed you were another user and I wasn't explaining myself very clearly. If you can fix the problem in the next update, that would be great.

I'm now using the previous version of App Connect, and it seems to me that the encoding is working. In any case, as long as the decoding is fixed and things will work as before.. fine.

Perhaps you are working on the advanced version of Server Connect. It would be a great improvement if it were capable of advanced queries. From my point of view it is by far the weakest aspect of the whole suite of extensions.
Replied 27 Mar 2017 09:09:47
27 Mar 2017 09:09:47 Teodor Kuduschiev replied:
Hi Tom,
This will be fixed in this week's update.
Replied 27 Mar 2017 09:16:38
27 Mar 2017 09:16:38 Tom Dupre replied:
Hi Teodor,
That would be great - thanks.
Replied 28 Mar 2017 13:55:51
28 Mar 2017 13:55:51 Teodor Kuduschiev replied:
Hi Tom,
Please update to the latest version, this issue is fixed there.

Reply to this topic