more work on expiration, make system limits useful - even in retrospect
This commit is contained in:
parent
1f427e0e5b
commit
63b8020969
@ -89,8 +89,11 @@ This document assumes you're an administrator.
|
|||||||
There also exist CLI utilities for performing this operation, which you
|
There also exist CLI utilities for performing this operation, which you
|
||||||
may prefer, especially if you're a large site.
|
may prefer, especially if you're a large site.
|
||||||
[b]system > default_expire_days[/b]
|
[b]system > default_expire_days[/b]
|
||||||
When creating a new channel, set the default expiration of connections
|
set the default expiration of connections' (matrix/network)
|
||||||
posts to this number of days.
|
posts to this number of days.
|
||||||
|
[b]system > expire_limit
|
||||||
|
Don't expire any more than this number of posts per channel per
|
||||||
|
expiration run to keep from exhausting memory. Default 5000.
|
||||||
[b]system > dlogfile[/b]
|
[b]system > dlogfile[/b]
|
||||||
Logfile to use for logging development errors. Exactly the same as
|
Logfile to use for logging development errors. Exactly the same as
|
||||||
logger otherwise. This isn't magic, and requires your own logging
|
logger otherwise. This isn't magic, and requires your own logging
|
||||||
|
@ -38,6 +38,9 @@ function expire_run($argv, $argc){
|
|||||||
logger('expire: start', LOGGER_DEBUG);
|
logger('expire: start', LOGGER_DEBUG);
|
||||||
|
|
||||||
$site_expire = get_config('system', 'default_expire_days');
|
$site_expire = get_config('system', 'default_expire_days');
|
||||||
|
|
||||||
|
logger('site_expire: ' . $site_expire);
|
||||||
|
|
||||||
if(intval($site_expire)) {
|
if(intval($site_expire)) {
|
||||||
$r = q("SELECT channel_id, channel_address, channel_pageflags, channel_expire_days from channel where true");
|
$r = q("SELECT channel_id, channel_address, channel_pageflags, channel_expire_days from channel where true");
|
||||||
}
|
}
|
||||||
@ -52,15 +55,18 @@ function expire_run($argv, $argc){
|
|||||||
if($rr['channel_pageflags'] & PAGE_SYSTEM)
|
if($rr['channel_pageflags'] & PAGE_SYSTEM)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(intval($site_expire) && (intval($site_expire) < intval($rr['channel_expire_days'])) ||
|
||||||
|
intval($rr['channel_expire_days'] == 0)) {
|
||||||
|
$expire_days = $site_expire;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$expire_days = $rr['channel_expire_days'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// if the site expiration is non-zero and less than person expiration, use that
|
// if the site expiration is non-zero and less than person expiration, use that
|
||||||
logger('Expire: ' . $rr['channel_address'] . ' interval: ' . ((intval($site_expire) && intval($site_expire) < intval($rr['channel_expire_days']))
|
logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $expire_days, LOGGER_DEBUG);
|
||||||
? $site_expire
|
item_expire($rr['channel_id'], $expire_days);
|
||||||
: $rr['channel_expire_days']), LOGGER_DEBUG);
|
|
||||||
item_expire($rr['channel_id'],
|
|
||||||
((intval($site_expire) && intval($site_expire) < intval($rr['channel_expire_days']))
|
|
||||||
? $site_expire
|
|
||||||
: $rr['channel_expire_days'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +80,18 @@ function expire_run($argv, $argc){
|
|||||||
$expire_days = get_config('system','sys_expire_days');
|
$expire_days = get_config('system','sys_expire_days');
|
||||||
if($expire_days === false)
|
if($expire_days === false)
|
||||||
$expire_days = 30;
|
$expire_days = 30;
|
||||||
|
|
||||||
|
if(intval($site_expire) && (intval($site_expire) < intval($expire_days))) {
|
||||||
|
$expire_days = $site_expire;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger('Expire: sys interval: ' . $expire_days, LOGGER_DEBUG);
|
||||||
|
|
||||||
if($expire_days)
|
if($expire_days)
|
||||||
item_expire($x['channel_id'],(($site_expire && $site_expire < $expire_days) ? $site_expire : $expire_days));
|
item_expire($x['channel_id'],$expire_days);
|
||||||
|
|
||||||
|
logger('Expire: sys: done', LOGGER_DEBUG);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -3922,6 +3922,10 @@ function item_expire($uid,$days) {
|
|||||||
|
|
||||||
$expire_network_only = 1;
|
$expire_network_only = 1;
|
||||||
|
|
||||||
|
$expire_limit = get_config('system','expire_limit');
|
||||||
|
if(! intval($expire_limit))
|
||||||
|
$expire_limit = 5000;
|
||||||
|
|
||||||
$sql_extra = ((intval($expire_network_only)) ? " AND not (item_flags & " . intval(ITEM_WALL) . ") > 0 " : "");
|
$sql_extra = ((intval($expire_network_only)) ? " AND not (item_flags & " . intval(ITEM_WALL) . ") > 0 " : "");
|
||||||
|
|
||||||
$r = q("SELECT * FROM `item`
|
$r = q("SELECT * FROM `item`
|
||||||
@ -3930,7 +3934,7 @@ function item_expire($uid,$days) {
|
|||||||
AND `id` = `parent`
|
AND `id` = `parent`
|
||||||
$sql_extra
|
$sql_extra
|
||||||
AND NOT ( item_flags & %d )>0
|
AND NOT ( item_flags & %d )>0
|
||||||
AND (item_restrict = 0 ) ",
|
AND (item_restrict = 0 ) LIMIT $expire_limit ",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
db_utcnow(), db_quoteinterval(intval($days).' DAY'),
|
db_utcnow(), db_quoteinterval(intval($days).' DAY'),
|
||||||
intval(ITEM_RETAINED)
|
intval(ITEM_RETAINED)
|
||||||
|
Reference in New Issue
Block a user