Closed (outdated)
Project:
Geocoder
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
11 Jul 2012 at 23:05 UTC
Updated:
15 Jan 2019 at 14:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
drewschmaltz commentedI have exactly the same problem. I was like "didn't this work before?" - now I realize it is only on edits when it doesn't work... let's try and figure it out - tell me if you've gotten anywhere.
Comment #2
drewschmaltz commentedThis code causes computed fields to be ignored always. Commenting out this "return FALSE" allows computed fields to be geocoded.
If I knew where to start I'd edit this code to deal with these fields properly, but I'm not really sure. Maybe someone more familiar with what is being done here could help...
Comment #3
dwalker51 commentedI had similar problems, but even on creating a new node with the following code: http://drupal.org/node/1534654#comment-6757108
Comment #4
drewschmaltz commentedConfirmed on created the new node. Check my post ^ - it fixes it, but isn't a fix.
Comment #5
varunity commentedThanks @drewschmaltz, this workaround helps!
Comment #6
drewschmaltz commentedOkay, so my fix only helped with editing and essentially used the data from the last form submission to create location data. The problem is that computed field runs on update. I simply added a presave function to computed_field and the problem was solved. I could even go back to geocoder and remove this comment.
Comment #7
greenskunkI have this issue with the Address field being geocoded and shown on an OpenLayers map is working on the Edit form, however, after you click save then the data is not saved in the geofield.
Is your fix specific to your computed field or did you modify a module?
Comment #8
greenskunkI recommend testing @phayes patch at http://drupal.org/node/1862922#comment-6980730
Comment #9
foopang commentedTested the patch from phayes, it doesn't solve this problem.
@drewschmaltz, you are right. The problem is that computed field runs on update, but geocoder check the source field value on presave. But I just can't figure out how to added a presave function to computed_field, would you please advise? Thanks so much.
Comment #10
lhugg commentedI was going to add this issue, but found it here. It seems that many of us are still having this problem.
From what I can see, geocoder_google_field in google.inc never executes when a computed field is used. Has any of the above been resolved, or is there any additional guidance on how to use a presave function to work around?
Comment #11
Morasta commented@drewschmaltz : can you elaborate on this presave function or share what you came up with?
Comment #12
adognameddog commentedI've had the same problem. I use the Geolocation module.
I changed the widget from Geocode from another field to Latitude/Longitude.
Next, I implemented the hook_field_attach_presave() hook. This is the code. It's not quite generic, so you'll have to see what parts you can reuse.
This is how I get the lat/lng from multiple fields. Note that street, number and city(part) are required fields in my setup. Do not just reuse this code, but check thoroughly.
Comment #13
khan2ims commentedI am using geofield in a user account page. As a very simple fix for presave function, I have added a rule with event "After updating an existing user account". Then added an action "Save entity". What it does is, it saves the user account page AGAIN after updating it first. This way the computed field is also getting updated.
I know this is not ideal fix, but it works for me!
Comment #14
zmove commentedSame problem here. Why geocoder is marked as compatible with computed on the module page whereas it doesn't seems to work ?
Comment #15
jsibley commented@khan2ims, what data selector are you using for your rule?
Thanks.
Comment #16
antonello.dipinto commentedany issue ?
thanks
Comment #17
Molfar commentedHere is the patch. It overheats some functionality from computedfield, but works fine.
Comment #18
simon georges commentedComment #19
candelas commentedSolved in last dev, so I close the issue. Now when you edit a event and the address is not changed, the geocoder coordinates don't get overridden to nothing.
Comment #20
candelas commentedAt the end I had to make a patch because it was not deleting the coordinates when it had an error #1293794: Geocoder doesn't clear Geofield if it receives a malformed address
Comment #21
khalor commentedThis is still an issue in the latest dev, even after applying patches cleanly from #17 and also the patch in #1293794-9: Geocoder doesn't clear Geofield if it receives a malformed address. The 'fix' in #2 solves the issue, but it's not a solution...
Comment #22
candelas commented@Khalor did they change the dev? I have a site going with the patch in #1293794-9: Geocoder doesn't clear Geofield if it receives a malformed address and it works well. I didn't use the patch in this issue.
Comment #23
khalor commentedThose patches aren't in dev yet (@candelas do you have module access?) so regardless this isn't resolved.
Looking at it closer it seems that #1293794: Geocoder doesn't clear Geofield if it receives a malformed address may(?) solve the edit/save issue, but my experience has been neither of those patches + dev allowed Computed Fields to be Geocoded on a node save on either edit or creation. So not sure what to mark this issue as (maybe RTBC if it's working for you?), and will move over to #1970288: computed field not geocoding for the more general computed field problem.
Comment #24
candelas commented@Khalor I have the patch #1293794-9: Geocoder doesn't clear Geofield if it receives a malformed address working in 7.x-1.2+18-dev that is the actual dev and it is working. Have you cleared cache? What isn't it working?
Comment #25
khalor commentedGeocoding from a computed field to a geofield doesn't work (on new node save or node edit) as it seems field value isn't computed (which it does on update) when geocoder runs (which it does on presave). So I think #1293794: Geocoder doesn't clear Geofield if it receives a malformed address is a separate issue, possibly allowing computed fields to be geocoded when a node is edited (although it'll be the old computed value that existed before the save/update) but new nodes still aren't geocoded so I don't think it's a true fix to this (editing) issue as it'll be using old values.
Comment #26
candelas commented@Khalor: I have just created a new event.
Which version are you using? I use 7.x-1.2+9-dev with the patch
Which other modules are you using?
Comment #27
puddyglum@candelas, I'm having this same issue, using 7.x-1.2+18-dev. When I Geocode from another field it simply never works. If I use Long/Lat it works fine. Is it working for you?
Comment #28
puddyglumI can replicate this pretty easily.
Drush 6:
drush qd geocode-1679926 --dev geofield geocoder geophp computed_field ctools
Manage fields of Basic Page
Add Computed field, set value to be "1600 Pennsylvania Avenue, Washington DC"
Add Geofield, set widget to be Geocode from another field, select Computed
Create a Basic Page
(no geofield)
Edit the Basic Page
(no geofield)
Unless I'm missing something obvious, geofield from computed field basically broken in dev and stable?
Comment #29
puddyglumMy workaround was to not use computed_field, and use addressfield instead. I used Rules to populate the Address Field values on a condition of "Before saving content". Then set Geocode from another field to the Address field. This works pretty well for me, although I'd rather use computed field for simplicity and flexibility.
IMO using Rules was so quick and easy that I think it should be the preferred method instead of Computed Field.
Comment #30
candelas commented@jmonkfish I use the Geocoder 7.x-1.2+18-dev , Geofield 7.x-2.1 and the patch in #1293794-9: Geocoder doesn't clear Geofield if it receives a malformed address and works.
Comment #31
puddyglumDowngraded to geofield-7.x-2.1 and applying that patch didn't make any difference, unfortunately. It seems like Khalor is having the same issue. It won't save for newly created content or for editing content.
Comment #32
capynet commentedHi, I had the same problem and after some debug I realized computed field was called after geocoder stores the values on node edit scenario.
I made 2 patches may help. The first one is for stable release and the second for dev code.
patch for stable was tested for two months right now without problem.
bye!
Comment #33
polThose last patch make sense to me.
Comment #34
rob.costello commented@capynet how are you setting your computed field? For me, setting the computed field value as per the module instructions ($entity_field[0]['value'] = 'bla') results in the geocoder_google function being passed an array and returning an error. I've created a patch which just takes the first value in this situation, but this won't work for multi-value computed fields so this might need a rethink.
Comment #35
rob.costello commentedComment #36
indigoxela commentedHi,
I'd like to test the latest patch, but unfortunately it won't apply.
First I have to add "-p 6", which is very uncommon for drupal patches, then I realize that it isn't compatible with latest geocoder code anymore.
@rob.costello and/or capynet could you please provide a compatible new patch?
Many thanks in advance.
Comment #37
pol