Drupal 4.7 with locations cvs installed. User enters his location in his user account form and saves it. When he revisits the edit portion of his account the location is still there - good. However if he changes any other values and hits submit, the location data disappears.

CommentFileSizeAuthor
#5 location.module_12.patch708 byteswebchick
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lunas’s picture

I am no having no success in sorting out this problem. Any help would be appreciated.

ajwwong’s picture

Title: Locations disappear when user edits his account » Locations disappear when user edits any of the items under the secondary menus of his account

I can confirm this issue, but let me spell out in more precise detail how it manifests on my system. [Title changed to reflect the bug, more specifically:
New title:
Locations disappear when user edits any of the items under the secondary menus of his account

Here's the behavior:

(1) User enters in location information under the menu setting

user/$user->uid/edit

So far, so good.

(2) However, when the user attempts to edit items that are in the SECONDARY menus underneath the "edit" tab, e.g., profile links, for example

user/$user->/edit/Personal+information

...or...

user/$user->/edit/Location+Map

the previously entered location information disappears. [Note, this bug remains even when gmap.module is disabled.]

Important bug -- possibly linked to the current incompatibility between gmap and location.module, imho. See also,

http://drupal.org/node/56590

and possibly

http://drupal.org/node/58793

Good luck!

Albert
www.ithou.org

webchick’s picture

Assigned: Unassigned » webchick

Yeah, nasty bug. I'm going to try and fix this for planetsoc.com, but it's 4:30am so no promises. ;)

Problem is coming in location_user:

  if ($op == 'update' || $op == 'insert') {
    if ($user_setting == LOCATION_USER_CIVICRM_ONLY) {
      // Do a bunch of CiviCRM stuff.
    }
    else {
      // Hey this is no good... $edit['location'] comes back empty!
      $edit['location'] = location_form2api($edit['location']);
    }
    ...
   // Why, sure! I'd be happy to go and delete your location info for you!
   _location_save($edit['location'] ? $edit['location'] : array(), $user, 'user');
   unset($edit['location']);
}

Investigating further...
Because this:

This line in location_user:

_location_save($edit['location'] ? $edit['location'] : array(), $user, 'user');

totally clears the

webchick’s picture

Bah. ;) Told you it was late. ;) Ignore after "investigating further..."

webchick’s picture

Status: Active » Needs review
FileSize
708 bytes

You gotta love those 1-liner patches that take you 4 hours to figure out. ;)

lunas’s picture

Heh, at least you only spent 4 hours on it, I've spent weeks...obviously I didn't know what I was looking for. Thanks so much for figuring it out.

ajwwong’s picture

hey, webchick! great fix!! Amazing.

btw, do you know if this solves the issue here :

http://drupal.org/node/56590

I want to make it so people don't have to enter their location information twice (once on the Location Map) and (once on the user/edit page)?

My guess is "No" and that people still have to enter their location information twice -- at least judging from your posting here...

http://2006.planet-soc.com/?q=node/119

Anyhow, thanks for a great fix...

Albert
www.ithou.org

webchick’s picture

Hi, Albert.

No, sorry... the fix for Gmap: Conflict with location.module requires changing Gmap module so that it saves user locations in a way that is compatible with location.module. webgeer is probably the best person for that particular job. :)

ajwwong’s picture

thanks for the response, webchick. appreciate it! :-)

oadaeh’s picture

I just ran into this bug (I actually ran into it about a week ago, but didn't realize it until today), and this patch worked great to fix the problem. Thanks!

ankur’s picture

Status: Needs review » Fixed

Committed to HEAD and DRUPAL-4-7. Thanks for the patch and reviews.

Anonymous’s picture

Status: Fixed » Closed (fixed)