I installed addressfiled, geocoder, geofield modules. I am not trying to do graphical maps at this point. Just addresses with proximity searches (location module does this but doesn't play well with Rules).

After I added a geo field to my users I then told it to get data from address field. When I save a user's new address I get this error:

Warning: Invalid argument supplied for foreach() in geocoder_widget_array_recursive_diff() (line 423 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

If I resave I do not get the error but I don't know if it's saving anything in the geofield or not. Also I can't see the geo field to see any type of data. Is it supposed to be visible?

I left all the settings at default settings.

Comments

IWasBornToWin’s picture

I just changed the geocoder handler from google to longitude/latitude thinking this is what I need for my proximity needs and I got this error after saving the user's address:

Notice: Undefined index: value in geocoder_latlon_field() (line 90 of /home4/growtogi/public_html/sites/all/modules/geocoder/plugins/geocoder_handler/latlon.inc).

phayes’s picture

You should be using the google handler. I'm surprised it even *let* you select the lat/lon handler for an adressfied. Or is the field a text-field?

IWasBornToWin’s picture

StatusFileSize
new205.08 KB

I switched it back but it gives me several choices - see screenshot.

http://drupal.org/files/geocode.jpg

phayes’s picture

You should be using "Google Geocoder".

phayes’s picture

Category: bug » support
IWasBornToWin’s picture

OK. I changed it back, registered a new user, collected their address information at registration and received these red error messages:

•Notice: Undefined property: stdClass::$language in geocoder_widget_get_field_value() (line 211 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).
•Warning: Invalid argument supplied for foreach() in geocoder_widget_array_recursive_diff() (line 423 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).
•Warning: Invalid argument supplied for foreach() in geocoder_widget_array_recursive_diff() (line 423 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

phayes’s picture

Hi IWasBornToWin,

Would you be able to produce a feature that has this bug and post it here?

IWasBornToWin’s picture

New feature request here http://drupal.org/node/1694526

Thanks for your quick replies, Phayes

phayes’s picture

Hi IWasBornToWin,

I think you misunderstood me. I was asking you to bundle up your content-type and fields using the "features" module and post it here as a .tar.gz file. Would you be able to do this?

IWasBornToWin’s picture

Sorry about that. I've never used features to do that before but I expect I could figure it out. Here are two things to consider though:

1. It's not a content type, It's for users.
2. I have TONS of custom fields in my user entity.

IWasBornToWin’s picture

I've noticed the errors from adding new content is because I have a rule that changes some user fields when this event occurs. It then throws a geocoder error after updating the user account. Also just noticed my captcha at registration is gone, not sure if this is related to geofield or geocoder yet.

IWasBornToWin’s picture

Captcha was irrelevant issue, sorry. The notice below is from registering a new account. The warnings originally posted come after rules updates a user account.

Notice: Undefined property: stdClass::$language in geocoder_widget_get_field_value() (line 211 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

IWasBornToWin’s picture

Still having problems with this -

Got this warning after adding new content that shows a view of the content related to the user. My only geofield field is in user entity.

Warning: Invalid argument supplied for foreach() in geocoder_widget_array_recursive_diff() (line 423 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

IWasBornToWin’s picture

This error seems to be coming from a conflict when I upload or edit a user photo in the user settings:

Hope that helps isolate the problem. I'm using module , http://drupal.org/project/user_picture_field also.

IWasBornToWin’s picture

IWasBornToWin’s picture

Now I get this error when saving new user account - Notice: Undefined property: stdClass::$language in geocoder_widget_get_field_value() (line 211 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

Rob_Feature’s picture

Title: Error when saving new address » Address Field Geocoding results in Undefined property: stdClass::$language
Category: support » bug
Priority: Normal » Major
Status: Fixed » Active

Saying "Delete the module and all the data and reinstall" is not considered "Fixed". There's something wrong causing this and that needs to be figured out. Marking as active and as a bug, since no one seems to know what's causing it.

For me, this doesn't happen when saving a node (it geocodes sucessfully), but only when running cron (when it tries to geocode the nodes).

netbek’s picture

@IWasBornToWin What field type are you using to store the address information? Text, long text, addressfield (module), location (module), etc.? If it's attached to the user entity, config should be at /admin/config/people/accounts/fields. It might help to narrow down the culprits if we knew what's failing to geocode.

Edit: You say you installed addressfield. Above is to confirm that's what you're geocoding from.

IWasBornToWin’s picture

StatusFileSize
new355.17 KB

Yes, addressfield module is what I'm using. It seems that anytime I change a user field, or a node with a user relationship I get the error.

Address field:
Format handlers
X Address form (country-specific)
Hide the country when only one is available
X Organisation (single line)
Name (First name, Last name)
Name (single line)

http://drupal.org/files/geo.jpg

netbek’s picture

StatusFileSize
new1.2 KB

OK, tested it. Got an "Invalid argument supplied for foreach() in geocoder_widget_array_recursive_diff()" warning when editing an existing user entity after adding the addressfield & geofield combo. The problem occurs when geocoder_widget_get_field_value() checks the original entity to see if another geocode is necessary. To reproduce the problem, remove and add the addressfield and geofield fields from the user entity, then edit a user. The same might occur with other entity & field combos when the original field value is empty.

Patch attached to make it more robust.

netbek’s picture

Status: Active » Needs review

Marking for review because I've reproduced the bug and have a patch [#20]

phayes’s picture

Status: Needs review » Fixed

Committed, thanks netbek. I'm marking this as fixed, but anyone should feel free to re-open if they are still seeing this issue.

IWasBornToWin’s picture

I just got this error :Notice: Undefined property: stdClass::$language in geocoder_widget_get_field_value() (line 211 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

I think it's the same as #16. I'm currently using latest dev geocoder and geophp. I haven't installed latest geofield dev yet.

After I installed latest geocoder two messages which used to appear (from orginal post, 423 error) are no longer appearing so thats great!

netbek’s picture

Status: Fixed » Active

Progress is good. I'm not sure if it's a factor, but what does your language config look like /admin/config/regional/language? Multiple languages, i18n module?

A quick Google suggests:
#1608836: entity->language doesn't always exist
#1461878: errors
#1495648: Introduce entity language support

Possibly we could just pass NULL if the entity language is not present, i.e.:

field_get_items($entity_type, $entity, $field_name, isset($entity->language) ? $entity->language : NULL)
IWasBornToWin’s picture

StatusFileSize
new208.67 KB

You may have lost me. Here is a screenshot of regional settings:
http://drupal.org/files/geo_0.jpg

netbek’s picture

I'm testing on a site that has the locale and internationalization modules enabled (to support multiple languages). I suspect entity language might be missing if locale isn't enabled. But I don't have time to test that at the moment unfortunately. I've attached a patch. It shouldn't do harm as $langcode is optional per documentation.

phayes’s picture

Thanks netbek. #26 has been committed. I'm optimistically marking this as fixed (again). Please feel free to re-open if any problems persist.

netbek’s picture

Status: Active » Fixed
IWasBornToWin’s picture

Just tried latest dev, unfortunately I still get the error when adding a new account.

Notice: Undefined property: stdClass::$language in geocoder_widget_get_field_value() (line 211 of /home4/growtogi/public_html/sites/all/modules/geocoder/geocoder.widget.inc).

IWasBornToWin’s picture

I just changed display from wkt to latitude/longitiude to see if it would help, and it doens't. Which setting do you recommend?

netbek’s picture

Are you sure you're using the latest version? The dev on the module home page doesn't contain the changes yet. You can get those now from git or wait until the module page updates.

I doubt wkt or lat/lon is the problem.

Edit: see http://drupal.org/project/geocoder/git-instructions if you're in a hurry.

IWasBornToWin’s picture

I must not be using the latest version. I thought "comitted" means it's in the latest version? I'm not in a huge hurry, I can wait a few hours! :) JK

IWasBornToWin’s picture

I'll just apply the patch.

IWasBornToWin’s picture

Applied patch, got no error! Thanks

phayes’s picture

There's a lag of a few hours (up to 12 I think) for commits to be picked up in the dev download.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jcnventura’s picture

Status: Closed (fixed) » Active

I've also did this step of creating the location field after already having some content. When using the latest dev version, I get this message (line 448). The value of $aArray1 is 'S'. Original field value was 'Sölden, Austria'.

jcnventura’s picture

Status: Active » Closed (fixed)

Sorry this happens because I'm geocoding from the 'Title' property, and this seems to only work with fields...