I've encountered the following when geocoding from a taxonomy term reference field. If the term is already in the db, it geocodes. If it's a new term, it doesn't because there isn't a tid yet. Using geocoder_google_field() as an example, here's what $field_item looks like for the term "London", which isn't in my db:

array(
	['tid'] => 'autocreate'
	['vid'] => 1
	['name'] => 'London'
	['vocabulary_machine_name'] => 'tags'
)

To fix this, instead of this:

$term = taxonomy_term_load($field_item['tid']);
return geocoder_google($term->name);

Perhaps this:

$term_name = $field_item['name'];
if (is_numeric($field_item['tid'])) {
  $term = taxonomy_term_load($field_item['tid']);
  $term_name = $term->name;
}
return geocoder_google($term_name);

The same would apply to the other geocoder_[handler]_field functions for mapquest_nominatim, yahoo, yandex. Is it necessary to use taxonomy_term_load() or could one use $field_item['name'] ?

Comments

simon georges’s picture

Status: Active » Needs review
StatusFileSize
new3 KB

Patch provided. All credits goes to netbek.

simon georges’s picture

Issue summary: View changes

Fixed typo

pol’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)