Closed (fixed)
Project:
Location
Version:
5.x-3.x-dev
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Reporter:
Created:
9 Sep 2008 at 19:05 UTC
Updated:
6 Nov 2008 at 20:02 UTC
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
Comment #1
bdragon commentedlocation_cck in location 5 has been patched.
Comment #2
bdragon commentedCommitted 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.
Comment #3
bdragon commentedNo reports of side effects, considering this done.
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
bdragon commentedReopening because I just found a bug related to the deleting or changing locations on the second revision of a node.
Comment #6
bdragon commentedOK, fixed it.
http://drupal.org/cvs?commit=148405
http://drupal.org/cvs?commit=148406
Comment #7
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.