I'm editing a node. The first time I save it everything goes fine, but when i edit it again and save, the location is lost. Note: I'm using 8 locations for the content type and filling only the first one.

Comments

mburak’s picture

Sorry, i was reviewing this again and the problem doesn't seem to be the submission. The problem is that it's loading the submitted location in the #8 place. Look at my database. It's saving the empty locations too.

mysql> select * from location_instance where nid=6930;
+------+------+------+-------+-----+
| nid | vid | uid | genid | lid |
+------+------+------+-------+-----+
| 6930 | 7196 | NULL | | 377 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 0 |
| 6930 | 7224 | NULL | | 377 |
+------+------+------+-------+-----+
9 rows in set (0.00 sec)

mysql> select * from location where lid=377;
+-----+------+---------------------+------------+----------+----------+-------------+---------+-----------+------------+--------+------------+
| lid | name | street | additional | city | province | postal_code | country | latitude | longitude | source | is_primary |
+-----+------+---------------------+------------+----------+----------+-------------+---------+-----------+------------+--------+------------+
| 377 | | 5101 Shawcrest Road | | Wildwood | NJ | 08210 | us | 38.991867 | -74.837250 | 3 | 0 |
+-----+------+---------------------+------------+----------+----------+-------------+---------+-----------+------------+--------+------------+
1 row in set (0.00 sec)

mysql> select * from node where nid = 6930;
+------+------+------------+-------------------+-----+--------+------------+------------+---------+---------+----------+--------+
| nid | vid | type | title | uid | status | created | changed | comment | promote | moderate | sticky |
+------+------+------------+-------------------+-----+--------+------------+------------+---------+---------+----------+--------+
| 6930 | 7224 | restaurant | Lighthouse Pointe | 1 | 1 | 1184507886 | 1221515405 | 2 | 0 | 0 | 0 |
+------+------+------------+-------------------+-----+--------+------------+------------+---------+---------+----------+--------+

mburak’s picture

I fixed this adding a condition in the location_save_locations function.

    foreach ($locations as $location) {
      if ($location['lid'] != 0) {
        $args[] = $location['lid'];
        db_query('INSERT INTO {location_instance} ('. implode(', ', $columns) .') VALUES ('. implode(', ', $placeholders) .')', $args);
        array_pop($args);
      }
bdragon’s picture

Status: Active » Fixed

Good call, fixed in HEAD and DRUPAL-5--3, thanks!
http://drupal.org/cvs?commit=140387
http://drupal.org/cvs?commit=140388

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.