Closed (fixed)
Project:
Geocoder
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Oct 2011 at 02:17 UTC
Updated:
11 Mar 2012 at 13:50 UTC
Notice: Trying to get property of non-object in GoogleGeocode->read() (line 51 of .../sites/all/libraries/geoPHP/lib/adapters/GoogleGeocode.class.php).
I get this error every time that I save a node containing an addressfield that I am trying to geocode into a geofield.
Comments
Comment #1
tlattimore commentedI am also getting this same error...
Comment #2
nod_Does it takes a really long time to save and fail ? I had this because of a connection timeout.
Comment #3
tlattimore commented@nod_ In my case it doesn't take a long to to save and fail. It just fails.
Comment #4
odavy commentedI'm getting this as well, every time.
Comment #5
goron commentedI'm also getting this error on every node save. Geocodes are not saved.
Comment #6
goron commentedInterestingly, I get this error only on my dev site on my server. It works fine locally. The URL for the request is being built fine, but it doesn't seem to return anything. Could this have something to do with server configuration? Are others on this page getting this problem in live environments too?
Comment #7
goron commentedOk. I figured it out.
It's a PHP setting called allow_url_fopen that needs to be on for the request method that file uses to work. In my server configuration it was off. You can turn it on in your php.ini file.
If you don't have access to your php.ini - I'm not sure if you can set that variable at runtime. Maybe with putenv()?
You can also solve this by changing the method used to do the request. Change the code in line 49 of GoogleGeocode.class.php from:
$this->result = json_decode(@file_get_contents($url));to:
$this->result = json_decode(drupal_http_request($url)->data);Comment #8
odavy commentedJust tried making the change in code you mention, restarted all services and cleared the cache, tried to create a new node and got the following error:
It did save the node though, just didn't do the geocode.
Comment #9
burgs commentedI too have allow_url_fopen enabled, but am getting the non-object error on line 51 as per the above comment. It does seem to be only on certain occasions that it will fail though.
I have narrowed the problem down to the fact that file_get_contents isn't working for some reason. I can browse to the url it generates though, so I'll keep looking.
Comment #10
vasikeindeed the #7 save the day, but this seems to be a geoPHP issue not a Geocoder one.
Comment #11
michaelfavia commentedIssue resolved? Please reopen if this is found to be geocoder and not geophp.
Comment #12
hampshire commentedI had this working and then it stopped with the above line 51 error. The only thing I can think of that I changed was installing the Gmap module. If I use Yahoo Placefinder to geocode that works but is not very accurate so I would prefer google. Any thoughts.
Comment #13
goron commentedHave you tried uninstalling Gmap and seeing if you still get the error?
Comment #14
hampshire commentedNo as it is now vital to the part of my site that is working but I just wanted to throw it out there and see if anyone else had similar issues though I did not see anyone else who had it working then had it stop working. I will try to clone the site and uninstall gmaps this weekend however and report back.
Comment #15
kvit commentedHad the same error.
Changing GoogleGeocode.class.php as described in #7 solved it. Thanks
Comment #16
hampshire commentedWent to test mine over the weekend and google just worked again, no need for the fix in #7 or any changes. Perhaps there was an issue with google itself the last time I was working on it.
Comment #17
R.J. Steinert commentedThis error occurs when the server requesting the coordinates from google does not receive a response which could be due to a timeout, or in my case my server didn't have access to google.com. The library from Google does not check if the response came back alright so folks are currently stuck with that non descriptive error. Ideally if the lookup fails, I think we should trigger some kind of error like "Address lookup failed. Try resubmitting." I'm not sure if we should patch geoPHP or the geocoder module...
Bug filed on geoPHP github https://github.com/phayes/geoPHP/issues/16
Comment #18
phayes commentedThis has been fixed in geoPHP. geoPHP now throws an exception. I believe that geocoder module checks for this and handles it, but I think it needs some verificaiton.
Comment #19
phayes commentedI've confirm that geocoder can deal with this. Marking as fixed