Problem/Motivation

In a situation when location saving attempt is performed on behalf of uid=0 (anonymous user), location_save_instance() deletes contents of location_instance table (since the module can't discern between anonymous user and node type, both are identified with the same 0 value (module architecture flaw?).

Proposed resolution

Something like this should be inserted to prevent table destruction:

if(
          !isset($criteria['nid'])
       && !isset($criteria['genid'])
       && !isset($criteria['lid']) &&
       isset($criteria['uid'])
       && $criteria['uid'] == 0
) {
   watchdog(
           'location',
           'location_save_locations: trap #1: attempt to setup location for anonymous user: @locations, @criteria',
           array(
               '@locations' => print_r($locations, TRUE),
               '@criteria' => print_r($criteria, TRUE)
           ),
           WATCHDOG_EMERGENCY);

   trigger_error(
           t(
                   'location_save_locations: trap #1: attempt to setup location for anonymous user: @locations, @criteria',
                   array(
                     '@locations' => print_r($locations, TRUE),
                     '@criteria' => print_r($criteria, TRUE)
                   )
           )
   );

   return;
}

Remaining tasks

Review required.