I setup a new Drupal site and installed the latest .dev versions of CCK, Location and GMap. I created a new content type 'Country', and gave it the location fields 'Country' and 'Coordinate Chooser' (both the overall location field and the individual fields within location were set to 'required').
I then attempted to create a node of type 'country' - I left the country field as the default (USA) and added a marker to the GMap (for the coordinates). I saved, but nothing appeared on the node page. Editing the node sees both country and coordinate fields empty. Nothing has been saved.
This only seems to happen when you leave the country as the default value. On another of my test sites, I had the default country as Australia, and trying to create an Australia node produced the same results. Changing to a different country seems to work though...
Also worth noting is the fact that setting the default country in both the Location configuration settings and per content type is buggy - it often doesn't work properly, or works every now-and-then, but not reliably.
Be good to get this confirmed and fixed.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 424784.patch | 1.33 KB | bdragon |
| #8 | location-424784-8.patch | 514 bytes | Anonymous (not verified) |
| #7 | location_issue_code.png | 24.71 KB | Anonymous (not verified) |
| #7 | location_issue_result.png | 35.05 KB | Anonymous (not verified) |
| #4 | location_cck.patch | 669 bytes | socki |
Comments
Comment #1
lolmaus commentedI confirm the bug.
No errors arise, but when you change coords in a node, the coord changes WILL NOT be saved (as if you clicked Back instead of Save).
If you change the country field in addition to the coords, the changes WILL be saved.
Comment #2
lolmaus commentedThis is not a matter of default country. It requires the country field to be changed, no matter whether you do that from default to custom, from custom to default or from custom to custom.
Comment #3
socki commentedI believe I might be having the same problem.
After doing a bit of digging, I think there might be an issue with how some of the data is being saved. It may also be a misconfiguration on my part. In either case, would you be able to point me in the right direction?
Please see the following screenshots:
node_locations_query.jpg - This is the query that is executed when you attempt to go to the "node locations" page. The first INNER JOIN makes the data in the location_instances table required.
location_instances.jpg - this is what is being stored in my location_instances table. As you can see, the NID and VID columns are all zero. This seems bad.
node_save_query.jpg - When I create a new node, saving the location data as part of it, these queries get executed. In here, the data is deleted, and when it gets recreated, it only sets the two columns... and NOT the NID or VID columns.
Please let me know if you may need any additional information, or if you may know what I might be doing incorrectly.
Thanks.
Comment #4
socki commentedI think i may have a potential fix for the issue I mentioned above.
It seems that the problem is that when location_save_locations is called from within location_cck_field the following is executed:
The patch I've attached will update this to be:
Note: The difference being the addition of the nid, vid and uid columns being passed into location_save_locations.
Since I'm new to using this module, I'm not entirely positive that this will have no negative impact, but with my implementation, it does appear to work just fine.
One thing that this may alter is if revisioning is enabled on the site. With the new parameters being passed in, an instance will be inserted for each revision. The reason for this is the existence of the vid in the table. The delete statement within location_save_locations deletes only exact matches of all the columns passed in.
Hope this helps.
Comment #5
yesct commentedthanks for posting a patch!
tagging.
I think there are some duplicates of this issue reported in the queue... but I dont have the time to find them. Maybe someone else could look, maybe search for "country default" or "country default save"
http://drupal.org/project/issues/search/location?text=default+country+sa...
Comment #6
Anonymous (not verified) commentedPatch doesn't work for me... When creating a country and leaving the country name as the default value (Australia), it still doesn't save properly - editing the country shows the name set to 'Please select'...
Comment #7
Anonymous (not verified) commentedI think I found where the problem lies...
I added the code in the first screenshot to location.module in the 'location_calc_difference' function (one of the functions that's run when deciding if any changes have been made - it should return TRUE for changes made). The code I added shows what happens to the location being checked before and after it's run through the 'location_strip' function. The result is shown in the second screenshot.
What it seems is happening, is that my coordinates are being stripped and hence when the location data is being checked, no changes are found and so nothing is saved to the database.
I'd submit a patch to fix this, but am not sure exactly what to fix (the problem lies in the 'location_strip' function somewhere). Any help would be much appreciated!
Comment #8
Anonymous (not verified) commentedI've made the following, very rudimentary patch that simply comments out the two strip() functions from the location_calc_difference() function in location.module.
Brief testing shows data is now being saved properly on my test site, but I don't know what effects, if any, this'll have on other parts of the code...
Hopefully this'll be a step in the right direction to getting this fixed...
Comment #9
yesct commentedComment #10
crizI can confirm this critical bug!
Patch from #8 is working, thx, but I don't think that this is an appropriate solution?
Comment #11
Anonymous (not verified) commentedIt's not. My site was going live and staff were going to start creating content with location data, so I needed it to work and came up with that patch.
As I said in #7 above, the problem (as far as I know) lies in the location_strip() function. I just stopped that function being run.
Comment #12
yesct commentedComment #13
summit commentedSubscribing, needing solution for this also.
Anyone has a prober solution?
Greetings, Martijn
Comment #14
dverkade commentedSubscribing, where experiencing the same problems. The patch does work, only partially, the selected location is altered when saved and is not displayed on the same location
Comment #15
gregstout commentedSubscribing, too.
Comment #16
jerodfritz commentedsubscribing
Comment #17
bdragon commentedSee if this helps, please.
Locpick is being stripped out, but I forgot to copy out the changes first.
Hopefully this works without introducing regressions.
Comment #18
bdragon commented(From #511378)
* Fix emptiness check centrally, instead of relying on location_save().
* Remove cck validator -- the condition it was checking for was a bug, not
a feature.
http://drupal.org/cvs?commit=244962
http://drupal.org/cvs?commit=244966
http://drupal.org/cvs?commit=244968
This should take care of this bug.