The Location CCK attempts to not create empty locations if no location information is provided. This works when creating nodes programmatically or via an import. However a cck node created or edited using the normal pages node/add/content_type and node/nnn/edit will create an empty location and attached it to the node even if the location is 'empty'.
The problem occurrs because of the Location CCK element 'cck_preview_in_progress'. This only appears in the location cck form and is not known to the location module that handles the empty location detection. To detect an empty location the location module builds an empty location in location_empty_location and then compares it against the provided location in location_calc_difference. To build the empty location the routine uses the defaults provided by calls to hook_locationapi but location_cck does not provide any defaults for cck_preview_in_progress. So the provided location includes cck_preview_in_progress but the empty location does not and the difference is found by location_calc_difference and the location determined to be 'not empty'.
There are two possible fixes, provide a default value for cck_preview_in_progress in location_cck_locationapi, which is probably good practice anyway, OR tell location_calc_difference that cck_preview_in_progress is unimportant when calculating the difference. The latter is done by setting the 'nodiff' flag, again in location_cck_locationapi.
Either solution should work and its probably best to implement both. However the 'nodiff' flag failed. The problem this time was in location_strip that removes the unimportant fields from a location. When deciding whether to strip it uses the line:
if(!($location[$k] == "locpick" || $location[$k] == "user_latitude" || $location[$k] == "user_longitude")) {
When $k was cck_prevoew_in_progress and $location[$k] = TRUE this returned false and the field was not stripped. I think this line should read:
if(!($k == "locpick" || $k == "user_latitude" || $k == "user_longitude")) {
as it is the keys we want to compare and not the field values.
So there are three fixes required:
1. Provide a default for cck_preview_in_progress in location_cck_locationapi
2. Add the 'nodiff' flag for cck_preview_in_progress in location_cck_locationapi
3. Fix location_strip in location.module to test keys rather than values.
Comment | File | Size | Author |
---|---|---|---|
#7 | 921578-empty-locations-6.patch | 1.51 KB | travist |
#6 | 921578-empty-locations-6.patch | 17.57 KB | travist |
#4 | 921578-empty-locations-4.patch | 1.65 KB | travist |
#2 | location_div.jpg | 25.13 KB | Ashford |
Comments
Comment #1
marcxy CreditAttribution: marcxy commented-subscribed
Comment #2
Ashford CreditAttribution: Ashford commentedThe technical terms in this issue are beyond my skill level; however, I think it is the same problem I have experienced. The Location heading and an empty map link displays on pages that do not contain a Location.
Location 6.x-3.1
Node Locations 6.x-3.1
Content 6.x-2.8
I have attached the screen print from my FireBug entry so you can see what is being printed.
Ashford
Comment #3
c-c-m CreditAttribution: c-c-m commentedSame here :(
Comment #4
travist CreditAttribution: travist commentedI was having this same issue.
The problem is that the location_saves are passing array's with the keys set, but all values as NULL when an empty location is set. This is failing all the validations.
Here is a patch that fixes it.
Comment #5
travist CreditAttribution: travist commentedComment #6
travist CreditAttribution: travist commentedNew patch for relative paths, and also better logic where it just unsets the bad locations...
Comment #7
travist CreditAttribution: travist commentedDisregard the previous patch.... used the wrong location version...
Here is the good one. :)
Comment #8
axiom3279 CreditAttribution: axiom3279 commentedPatch #7 didn't do any thing to fix this issue for me, still having location cck field values disappear on save. My setup:
Drupal 6.22
location 6.x-3.1
gmap 6.x-1.1
Will come back to it in a couple of days
Comment #9
podarokbumping version
needs work due to #8
Comment #10
legolasboClosing old D6 issues as D6 is end of life