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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcxy’s picture

Version: 6.x-3.x-dev » 6.x-3.1

-subscribed

Ashford’s picture

FileSize
25.13 KB

The 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

c-c-m’s picture

Same here :(

travist’s picture

I 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.

travist’s picture

Status: Active » Needs review
travist’s picture

New patch for relative paths, and also better logic where it just unsets the bad locations...

travist’s picture

Disregard the previous patch.... used the wrong location version...

Here is the good one. :)

axiom3279’s picture

Patch #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

podarok’s picture

Version: 6.x-3.1 » 6.x-3.x-dev
Status: Needs review » Needs work

bumping version
needs work due to #8

legolasbo’s picture

Status: Needs work » Closed (outdated)

Closing old D6 issues as D6 is end of life