• 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.

Geocode Cron Plugin and Greek Characters in Address

Status
Not open for further replies.

nirotheo

New Member
I have installed the geocode schedule task plugin to update the map element on my entries.
The problem is that i use Greek Characters for the Address, City and Country elements.
When i run the scheduled task i get the message "0 records updated"
For example i have one entry with the following address: ????? 10, ????? 26222 ??????
When i look at the logs i see the below:
"Error (ZERO_RESULTS), id 1 , no geocode result for: %26Kappa%3B%26omicron%3B%26rho%3B%26alpha%3B%CE%AE+10%2C%26Pi%3B%CE%AC%26tau%3B%26rho%3B%26alpha%3B%2C26222%2C%CE%95%CE%BB%CE%BB%CE%AC%CE%B4%CE%B1"

At some point the plugin converts the greek characters "????? 10, ????? 26222 ??????" to the below:
%26Kappa%3B%26omicron%3B%26rho%3B%26alpha%3B%CE%AE+10%2C%26Pi%3B%CE%AC%26tau%3B%26rho%3B%26alpha%3B%2C26222%2C%CE%95%CE%BB%CE%BB%CE%AC%CE%B4%CE%B1

If i change the address to English (Greeklish) characters everything works great.

Any ideas?

Thank you.
 
Try editing this file on your server:

./plugins/fabrik_cron/geocode/geocode.php

https://github.com/Fabrik/fabrik/blob/master/plugins/fabrik_cron/geocode/geocode.php#L221

... and at the indicated line (221), try replacing ...

Code:
                            $full_addr = urlencode($full_addr);

... with ...

Code:
                            $full_addr = urlencode(utf8_encode($full_addr));

if that doesn't work, try just ...

Code:
                            $full_addr = utf8_encode($full_addr);

.... but I think we still need to urlencode() the utf_encode'ed string, in case the address contains non URL-safe characters like &.

-- hugh
 
Thank you cheesegrits but with either of the 2 proposed changes i get the below logs:

1. "Total encoded: 0"

2. "Error (), id 1 , no geocode result for: %26Kappa%3B%26omicron%3B%26rho%3B%26alpha%3B%C3%8E%C2%AE+10%2C%26Pi%3B%C3%8E%C2%AC%26tau%3B%26rho%3B%26alpha%3B%2C26222%2C%C3%8E%C2%95%C3%8E%C2%BB%C3%8E%C2%BB%C3%8E%C2%AC%C3%8E%C2%B4%C3%8E%C2%B1"

3. 8,Trying to get property of non-object,/var/www/vhosts/etra.gr/holisticlife.gr/new/plugins/fabrik_cron/geocode/libs/gmaps2.php,76
 
Hmmm, that third error means you aren't getting a response from Google at all.

Are you testing this on a local host?

I noticed while testing the fix I suggested earlier that geocoding wasn't working at all from my local host, because my XAMPP install doesn't have a valid "cert bundle", and in more recent versions of PHP, "verify peers" is the default for connecting through https ... and the geocde API is https. And if your server doesn't have a valid cert bundle (which most Windows web server stacks don't), it'll fail.

I've just committed a fix for this. We already have a "Verify Peers" option in the Fabrik global settings, and I've modified the geocode plugin to check that setting, and if it is set to No, turn off verification for the geocode call.

So ... try doing a github update (see wiki), and see if that fixes the problem. You'll also need to set "Verify Peers" to No in the global settings.

-- hugh
 
Thanks for the quick response.

I use it on a live CentsOS Server with PHP 5.6.34.
I don't think it has something to do with the "cert bundle" because if i use english characters in the address elements it works fine. The problem occurs only with Greek characters.
If i edit the record on the front end and hit the button locate it works even with greek characters.
But when i run the cron it converts the greek letter ? to %26Kappa%3B and maybe this way it cannot locate the address.

I update the plugin from githtub and tried, then i made again the proposed changes on line 221 but it didnt work. :/
 
Well, it works in your browser because your browser automatically encodes those characters. Sending from the server, our code has to encode them. And the cert bundle / SSL verify doesn't affect your browser either. That's a PHP specific thing.

And ... if I test with your address string, it works as-is, with the urlencode(), without any changes. Here's a debug session, looking at the variables as the code runs ...

https://www.screencast.com/t/Gw7JuauEC4r

I've got 5 records in that table, one with French characters, and yours with Greek. As you can see, yours urlencodes, but to a completely different string:

Code:
%CE%9A%CE%BF%CF%81%CE%B1%CE%AE+10%2C+%CE%A0%CE%AC%CF%84%CF%81%CE%B1+26222+%CE%95%CE%BB%CE%BB%CE%AC%CE%B4%CE%B1

... and works, I get an "englishified" address and a lat/lon back from Google.

So I'm still trying to figure out what the problem is.

What encoding and collation do you have your table and address column(s) set to? I had to set mine to character set "Greek (ISO 8859-7)" and collation "greek_general_ci" to get it to correctly save those characters in the database, so I could test.

-- hugh
 
Hi again,
I have changed my table and fields collation to "greek_general_ci" and still the same.
I don't see any option to change the character set in PHPMyAdmin i think it is along with collation.
I tried setting the address directly on line 221 in file geocode.php like below and it worked: $full_addr = urlencode('????? 10, ?????');

I tried to see how the $full_addr is before urlencode($full_addr) and it looks like below if that helps:
Κορα\u03ae 10,Π\u03acτρα,26222,\u0395\u03bb\u03bb\u03ac\u03b4\u03b1"
 
Yeah, it looks like you have a character set / collation issue. As you can see from my screencast, with those set correctly for greek, the string shows correctly, no encoding, before the urlencode(). But I had to re-enter that string into my form again after changing the encoding, to get it to encode correctly.

Did you re-enter the data after changing your character set / collation? If you entered the data with those not set correctly, the data would have been incorrectly encoded into the database.

-- hugh
 
$full_addr = urlencode(html_entity_decode ($full_addr,null,'UTF-8'));
is doing on my site (with DB/table/column collation UTF-8)
 
OK, I've committed troester's fix:

https://github.com/Fabrik/fabrik/commit/c6e8f1130bf3cca51d1420c3f1cf874a01583100

I also changed my encoding to utf8 and collation to utf8-general-ci.

Turns out the reason I couldn't replicate this was that my address field wasn't being shown in the list. But elements which are shown in the list, we do run through htmlentities(). As soon as I set my element to show in list, I got the exact same string you did.

The good news is that the above commit fixes it. So, either do a full github update, or just change that line to ...

Code:
                            $full_addr = urlencode(html_entity_decode($full_addr, ENT_QUOTES));

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top