I am in the middle of implementing an optimization to the COW system to reuse lids if there are one or less instances of the lid.

This will affect how anyone using location_save must handle messing around with {location_instance}.

Old way:

if (!empty($node->locations)) {
  db_query('DELETE FROM {location_instance} WHERE vid = %d', $node->vid);
  foreach (array_keys($node->locations) as $key) {
    $lid = location_save($node->locations[$key], TRUE);
    if ($lid) {
      db_query('INSERT INTO {location_instance} (nid, vid, lid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $lid);
    }
  }
}

New way:

if (!empty($node->locations)) {
  foreach (array_keys($node->locations) as $key) {
    location_save($node->locations[$key], TRUE);
  }
  db_query('DELETE FROM {location_instance} WHERE vid = %d', $node->vid);
  foreach ($node->locations as $location) {
    db_query('INSERT INTO {location_instance} (nid, vid, lid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $location['lid']);
  }
}

This is needed because to improve the efficiency of location_save, it will now be checking whether or not a location is used in multiple places (revisions, or whatever) or not -- if not, it can reuse the previous lid. This will reduce table bloat, especially when garbage collection is turned off or cron is not running.

Comments

bdragon’s picture

location_cck in location 5 has been patched.

bdragon’s picture

Status: Active » Postponed (maintainer needs more info)

Committed to DRUPAL-5--3 and HEAD.
http://drupal.org/cvs?commit=139039
http://drupal.org/cvs?commit=139040

Setting to needs more info for a bit while ensuring this doesn't have any side effects.

bdragon’s picture

Status: Postponed (maintainer needs more info) » Fixed

No reports of side effects, considering this done.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

bdragon’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active

Reopening because I just found a bug related to the deleting or changing locations on the second revision of a node.

bdragon’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)

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