provide a way to sync locations and get rid of bogus hublocs, now implemented
This commit is contained in:
@@ -46,6 +46,8 @@ function prune_hub_reinstalls() {
|
||||
|
||||
function remove_obsolete_hublocs() {
|
||||
|
||||
logger('remove_obsolete_hublocs',LOGGER_DEBUG);
|
||||
|
||||
// Get rid of any hublocs which are ours but aren't valid anymore -
|
||||
// e.g. they point to a different and perhaps transient URL that we aren't using.
|
||||
|
||||
@@ -66,7 +68,9 @@ function remove_obsolete_hublocs() {
|
||||
if((! $r) || (! count($r)))
|
||||
return;
|
||||
|
||||
// Good. We have at least one valid hubloc.
|
||||
$channels = array();
|
||||
|
||||
// Good. We have at least one *valid* hubloc.
|
||||
|
||||
// Do we have any invalid ones?
|
||||
|
||||
@@ -74,25 +78,38 @@ function remove_obsolete_hublocs() {
|
||||
dbesc(get_config('system','pubkey')),
|
||||
dbesc(z_root())
|
||||
);
|
||||
if(! $r)
|
||||
return;
|
||||
|
||||
logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.');
|
||||
|
||||
// We've got invalid hublocs. Get rid of them.
|
||||
|
||||
$r = q("delete from hubloc where hubloc_sitekey = '%s' and hubloc_url != '%s'",
|
||||
$p = q("select hubloc_id from hubloc where hubloc_sitekey != '%s' and hubloc_url = '%s'",
|
||||
dbesc(get_config('system','pubkey')),
|
||||
dbesc(z_root())
|
||||
);
|
||||
if(is_array($r) && is_array($p))
|
||||
$r = array_merge($r,$p);
|
||||
|
||||
// We should probably tell everybody... But we don't have an easy way to do this
|
||||
// for the entire site. We'd have to do a channel at a time.
|
||||
// They will find out anyway - it just might take a little while.
|
||||
if(! $r)
|
||||
return;
|
||||
|
||||
// FIXME we probably also need to check that the sys channel has a valid hubloc
|
||||
// and re-create it if it doesn't.
|
||||
// We've got invalid hublocs. Get rid of them.
|
||||
|
||||
logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.');
|
||||
|
||||
$interval = ((get_config('system','delivery_interval') !== false)
|
||||
? intval(get_config('system','delivery_interval')) : 2 );
|
||||
|
||||
foreach($r as $rr) {
|
||||
q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d limit 1",
|
||||
intval(HUBLOC_FLAGS_DELETED),
|
||||
intval($rr['hubloc_id'])
|
||||
);
|
||||
|
||||
$x = q("select channel_id from channel where channel_hash = '%s' limit 1",
|
||||
dbesc($rr['hubloc_hash'])
|
||||
);
|
||||
if($x) {
|
||||
// proc_run('php','include/notifier.php','location',$x[0]['channel_id']);
|
||||
// if($interval)
|
||||
// @time_sleep_until(microtime(true) + (float) $interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user