sync_locations() toggle DB flag functions were broken - result of postgres changes. Split these into seperate set and reset blocks.
This commit is contained in:
@@ -1988,13 +1988,23 @@ function sync_locations($sender,$arr,$absolute = false) {
|
||||
}
|
||||
}
|
||||
|
||||
if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary']))
|
||||
|| ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) {
|
||||
if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) {
|
||||
$m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d",
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['hubloc_id'])
|
||||
);
|
||||
$r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY;
|
||||
hubloc_change_primary($r[0]);
|
||||
$what .= 'primary_hub ';
|
||||
$changed = true;
|
||||
}
|
||||
elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary'])) {
|
||||
$m = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d",
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['hubloc_id'])
|
||||
);
|
||||
// make sure hubloc_change_primary() has current data
|
||||
$r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY;
|
||||
hubloc_change_primary($r[0]);
|
||||
@@ -2009,8 +2019,7 @@ function sync_locations($sender,$arr,$absolute = false) {
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted']))
|
||||
|| ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) {
|
||||
if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) {
|
||||
$n = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d",
|
||||
intval(HUBLOC_FLAGS_DELETED),
|
||||
dbesc(datetime_convert()),
|
||||
@@ -2019,6 +2028,15 @@ function sync_locations($sender,$arr,$absolute = false) {
|
||||
$what .= 'delete_hub ';
|
||||
$changed = true;
|
||||
}
|
||||
elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted'])) {
|
||||
$n = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d",
|
||||
intval(HUBLOC_FLAGS_DELETED),
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['hubloc_id'])
|
||||
);
|
||||
$what .= 'delete_hub ';
|
||||
$changed = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user