I recently moved a drupal site from local to host and now geocoding no longer works.
When I go to the location configuration page and go on to the geocoding tab I get the following error:
Notice: Undefined property: stdClass::$data in google_geocode_country_list_xml() (line 17 of /home/truth/www/sites/all/modules/location/geocoding/google.inc).
Notice: Trying to get property of non-object in google_geocode_country_list_xml() (line 24 of /home/truth/www/sites/all/modules/location/geocoding/google.inc).
Notice: Trying to get property of non-object in google_geocode_country_list() (line 54 of /home/truth/www/sites/all/modules/location/geocoding/google.inc).
Warning: Invalid argument supplied for foreach() in google_geocode_country_list() (line 54 of /home/truth/www/sites/all/modules/location/geocoding/google.inc).
How to reproduce a bug #1269914-17: Geocoding no longer working (google.inc)
Does anyone know what's going on here? I've tried everything I can think of (reinstalling modules, new googlemaps api key etc...).
Any help would be appreciated!
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | Location_7_x-3_x-dev__fix_geocoding_options.patch | 2.59 KB | flyke |
| #17 | google-inc.jpg | 156.54 KB | bstrange |
| #8 | geocoding.jpg | 99.74 KB | bstrange |
Comments
Comment #1
Corbey commentedIt works perfectly on the local version, does anyone know why this would be?
Comment #2
ankur commentedIt looks like it's trying to grab the list of countries supported by the Google geocoder, but isn't able to do so for some reason. I'd say check the status page and see if it's possible to check for new updates or, better yet, if there is an error about drupal_http_request() failing. If that's the case, then there's probably an issue with your host being able to send off HTTP requests from within PHP.
Comment #3
Taxoman commentedComment #5
summit commentedHi,
I open this again if thats ok. I have the same issue.
May be it has to do with the newer php 5.3 version which my provider has installed?
Other versions than php 5.1.0 seems to have other coding standards?:
Greetings, Martijn
Comment #6
millenniumtreeAlso receiving these Undefined property: stdClass::$data in google_geocode_country_list_xml() errors.
We have a CentOS box that can't lookup IP addresses with PHP's fsockopen. For every domain we need the server to look up, we have to put it in the hosts file. Recaptca breaks because of this too.
Try putting spreadsheets.google.com into your /etc/hosts file.
It's a terrible solution, but that's what we have to do for the time being until we can find the real root of the problem.
UPDATE: The problem may be related to IPv6 on the server. Waiting for a config file solution from our hosting provider and I'll post it here. He claims that disabling IPv6 and rebooting will fix the problem. I also found some forum posts indicating that some firewalls can block the NS Lookup packets - but that would presumably block any lookups e.g. 'nslookup', 'ping'.
Comment #7
millenniumtreeThe solution for our CentOS servers (3 of them, experiencing the same issues), was to disable IPv6.
This went in our /etc/modprobe.conf file and then reboot the machine
Comment #8
bstrange commentedI am having the same problem, geocoding does not work on any of my sites (over a dozen). This issue does not appear to be exclusive to either D6 or D7 core or their associated location modules. On D6 with Location version 6.x-3.2 it does not download any Google information for the country list or list Google Maps as an option for any country and generates this error:
Type php
Date Tuesday, September 10th, 2013
User (removed by bstrange)
Location http://www.sanduskyspotlight.com/admin/settings/location/geocoding
Referrer http://www.sanduskyspotlight.com/admin/settings/location
Message Invalid argument supplied for foreach() in /home/sandusky/public_html/sites/all/modules/location/geocoding/google.inc on line 54.
Severity error
Hostname (removed by bstrange)
Operations
On Drupal 7, it fails to update geocoding providers, but generates a different set of errors:
• Notice: Undefined property: stdClass::$data in google_geocode_country_list_xml() (line 17 of /home/myseriou/public_html/swcgastro.com/sites/all/modules/location/geocoding/google.inc).
• Notice: Trying to get property of non-object in google_geocode_country_list_xml() (line 24 of /home/myseriou/public_html/swcgastro.com/sites/all/modules/location/geocoding/google.inc).
• Notice: Trying to get property of non-object in google_geocode_country_list() (line 54 of /home/myseriou/public_html/swcgastro.com/sites/all/modules/location/geocoding/google.inc).
• Warning: Invalid argument supplied for foreach() in google_geocode_country_list() (line 54 of /home/myseriou/public_html/swcgastro.com/sites/all/modules/location/geocoding/google.inc)
What is the url it tries to call to obtain the geocoding providers?
Previously, someone had said it was spreadsheets.google.com; however when I bring that up in a browser window it redirects to https://accounts.google.com/ServiceLogin?service=writely&passive=1209600...
I'm not sure what the issue is, and I'm leaning towards a misconfigured setting with my host since it effects all my sites and various versions of Drupal core and the Location module; however, I'd like to point them in the right direction if possible :)
Any help would be greatly appreciated!
Comment #9
hutch commentedI've just had a look at geocoding/google.inc.
There is obsolete code in there:
function google_geocode_country_list_xml() stems from the days when google supported a limited set of countries, no longer needed.
function google_geocode_country_list() refers to function google_geocode_country_list_xml(), that needs to be refactored to remove the xml filter.
function google_geocode_location() works fine.
function google_geocode_settings() has obsolete stuff regarding keys which is now no longer a requirement.
There is also a setting for geocoding accuracy which refers to function location_google_geocode_accuracy_codes() which reflects version 2 google API, I see nothing comparable in the docs at https://developers.google.com/maps/documentation/geocoding/
function _google_geocode_flatten() is probably OK
Comment #10
bstrange commentedSo basically this will require a patch to fix? Or can the error and inability to choose Google Maps as the default geocoding provider be safely ignored?
I have been unable to get gmap displays to show up on any sites that didn't already have Google Maps selected as the default geocoding provider for the United States.
I.e. none of my sites can access the geocoding tab in location without throwing the above errors specific to either D6 or D7 depending on the site; however, many of the sites at one point had Google Maps selected as the default geocoding option and all of those sites can display gmaps. My newer sites cannot choose Google Maps as the default geocoding option for the US and none of those sites display gmap content at all, even when exporting/importing the content type, views, etc that allows gmap to be viewed currently on my sites that previously selected Google Maps as default...
wow that was a mouthful 0.0
Comment #11
hutch commentedgoogle.inc needs fixing. On further investigation of the google docs I found that there are accuracy codes so I was wrong about that.
Comment #12
Wouter Van den Bosch commentedAt the risk of polluting this topic :
I am suddenly having issues with GeoCoding as well. Belgium for me.
About to dig into the code as well now, but might this have something to do with the V2 API's deprecation as of september 9 2013 ?
https://developers.google.com/maps/articles/geocodingupgrade
Had no issues before yesterday. Same codebase.
Comment #13
Wouter Van den Bosch commentedDisregard my comment. My issues were due to obselete V2 code and an older version of google.inc
Comment #14
bstrange commentedSo basically, any new sites will not be able to display Google Maps / gmap data on their site until this is fixed? Without being able to set Google Maps as the default provider for my country in the Geocoding Options, gmap does not display regardless of if I use location + gmap + views, or the older location / node location + location block method (personally, I prefer the views method).
Interestingly, all my sites that were configured to display location / gmap views prior to about June of this year still display their gmaps on location nodes; however, if I click the geocoding options tab on those sites, it returns the same errors, does not list Google Maps under the options column, and lists "No service selected for country." under the configure column.
I'm completely at a loss here as just about every site I have ever built on Drupal has required some utilization of gmap, and currently I can't get any maps to show at all :(
Comment #15
podarokbetter title and status
Comment #16
podarokrelated #2072869: Google geocoding not always accurate for partial addresses
Comment #17
bstrange commentedYou probably already know this but since you changed the status to 'maintainer needs more info', I thought I'd post it just in case: Unlike #2072869: Google geocoding not always accurate for partial addresses, this error occurs before anything else is configured. I installed Drupal 7, then Location & Gmap and nothing else. Immediately following installation you can click on the Geocoding Options tab and produce this error / see the attached results.
(Off the wall and probably pointless idea) I know when I set up Drupal 7, it gives me a form during install to select the default country... I wonder if I were to leave it as 'None Selected' if it would produce the same error when accessing the admin/config/content/location/geocoding page?
Comment #18
podarokthanks
Comment #19
bstrange commentedOk so I found a definitive reason for the errors / inability to download the country / provider table thanks to some help from my hosting company. Per their technician (I have added my own clarifications in brackets):
After finding this out, I contacted all the major hosting companies and found that none of them allow outgoing IPV6 connections for their shared hosting accounts. As you know, the majority of small to medium sized businesses use shared hosting to avoid the expense of dedicated hosting accounts.
So the big questions are: Is it Google's API that is requiring the connection over IPV6, or is it just the way the code in the Location module is set up? If it is Google, is there a way around it? and if it is the Location module code base, is that something that can be modified? because I would be willing to bet the vast majority of Drupal users utilize shared hosting accounts.
Hope this helps a little, and if I find out anything more from my host, I'll pass it along :)
Comment #19.0
bstrange commentedUpdated issue summary.
Comment #20
ssankarsiva commentedSolved , I am using drupal 6 , i had issue on geocode country not listed .
drupal_http_request() replaced in google.inc file . then i got list and working fine using https://drupal.org/project/chr .
Comment #21
rooby commentedI feel like this is a bug.
Comment #22
dkane commentedHas anyone encountered a solution for D7 that doesn't require enabling IPv6 connections on the host?
Comment #23
hutch commentedOn #21, the function google_geocode_country_list_xml() in google.inc is obsolete, Google no longer do their geocoding on a per-country basis so function google_geocode_country_list() needs to just return the $countries variable. If you want to let admins munge the countries list then provide support for the countries module.
Comment #24
egfrith commentedThanks hutch. Following your suggestion, I've put a patch at #2406483-12: Gecoding options crash in geocoding/google.inc, which I think is a more appropriate location, as the original bug on this thread was probably different.
Comment #25
flyke commentedAfter a fresh install of the latest location DEV version (7.x-3.x-dev), when going to admin/config/content/location/geocoding I got these errors:
Just like Corbey's screenshots, for most countries, in the options it says 'None supported.'.
This is fixed by editing the file google.inc and replacing the entire function google_geocode_country_list() with just this:
Other patches i've seen were for D6 or did not apply without problems, so I wrote my own patch for this.
Hope this helps others with the same problems.
p.s. if you cannot open admin/config/content/location/geocoding because it gives you a white pages with an error, then you probably don't have latest dev version of the module. You can fix this by editing the google.inc file and replacing the line
cache_set('location_google', $xml->asXML());with this:
There are 2 instances, so you need to replace both lines.
Comment #26
podarokComment #27
Chetna_Negi commented@flyke, your fix for google_geocode_country_list() worked very cleanly. Thanks
Comment #28
Chetna_Negi commented@flyke, your following fix worked very cleanly. Thanks
Comment #29
legolasboLet's see what testbot currently thinks of the patch.