aboutsummaryrefslogtreecommitdiffstats
path: root/include/expire.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-04-23 19:49:41 -0700
committerfriendica <info@friendica.com>2015-04-23 19:49:41 -0700
commit6679734135fb04f4a7beccb81663bf1e9574f062 (patch)
tree887488543d98b5dd297d917718bdd99844e83ba5 /include/expire.php
parent08b757a22cd2804bfec8ecf682b6987b8c06ca49 (diff)
parentc696860cc53bc25558d83de5eda65d9b583da382 (diff)
downloadvolse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.gz
volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.bz2
volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.zip
Merge branch 'master' into tres
Conflicts: include/Contact.php include/ItemObject.php include/api.php include/attach.php include/diaspora.php include/dir_fns.php include/enotify.php include/event.php include/expire.php include/items.php include/notifier.php include/notify.php include/photos.php include/taxonomy.php include/text.php include/widgets.php include/zot.php mod/admin.php mod/channel.php mod/dirsearch.php mod/display.php mod/editwebpage.php mod/events.php mod/home.php mod/item.php mod/manage.php mod/mood.php mod/network.php mod/page.php mod/photos.php mod/ping.php mod/post.php mod/thing.php mod/viewsrc.php view/css/mod_events.css
Diffstat (limited to 'include/expire.php')
-rw-r--r--include/expire.php84
1 files changed, 60 insertions, 24 deletions
diff --git a/include/expire.php b/include/expire.php
index b0bf55e4f..8ba9f746b 100644
--- a/include/expire.php
+++ b/include/expire.php
@@ -1,4 +1,7 @@
-<?php /** @file */
+<?php
+/**
+ * @file include/expire.php
+ */
require_once('boot.php');
require_once('include/cli_startup.php');
@@ -7,58 +10,91 @@ function expire_run($argv, $argc){
cli_startup();
+ // perform final cleanup on previously delete items
+
$r = q("select id from item where item_deleted = 1 and not (item_restrict & %d)>0 and changed < %s - INTERVAL %s",
intval(ITEM_PENDING_REMOVE),
db_utcnow(), db_quoteinterval('10 DAY')
);
- if($r) {
- foreach($r as $rr) {
- drop_item($rr['id'],false,DROPITEM_PHASE2);
+ if ($r) {
+ foreach ($r as $rr) {
+ drop_item($rr['id'], false, DROPITEM_PHASE2);
}
}
// physically remove anything that has been deleted for more than two months
+ /** @FIXME - this is a wretchedly inefficient query */
- $r = q("delete from item where ( item_restrict & %d )>0 and changed < %s - INTERVAL %s",
+ $r = q("delete from item where ( item_restrict & %d ) > 0 and changed < %s - INTERVAL %s",
intval(ITEM_PENDING_REMOVE),
db_utcnow(), db_quoteinterval('36 DAY')
);
- // make this optional as it could have a performance impact on large sites
+ /** @FIXME make this optional as it could have a performance impact on large sites */
- if(intval(get_config('system','optimize_items')))
+ if (intval(get_config('system', 'optimize_items')))
q("optimize table item");
logger('expire: start', LOGGER_DEBUG);
-
- $r = q("SELECT channel_id, channel_address, channel_expire_days from channel where channel_expire_days != 0");
- if($r && count($r)) {
- foreach($r as $rr) {
- logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $rr['channel_expire_days'], LOGGER_DEBUG);
- item_expire($rr['channel_id'],$rr['channel_expire_days']);
+ $site_expire = get_config('system', 'default_expire_days');
+
+ logger('site_expire: ' . $site_expire);
+
+ $r = q("SELECT channel_id, channel_address, channel_pageflags, channel_expire_days from channel where true");
+
+ if ($r) {
+ foreach ($r as $rr) {
+
+ // expire the sys channel separately
+ if ($rr['channel_pageflags'] & PAGE_SYSTEM)
+ continue;
+
+ // service class default (if non-zero) over-rides the site default
+
+ $service_class_expire = service_class_fetch($rr['channel_id'], 'expire_days');
+ if (intval($service_class_expire))
+ $channel_expire = $service_class_expire;
+ else
+ $channel_expire = $site_expire;
+
+ if (intval($channel_expire) && (intval($channel_expire) < intval($rr['channel_expire_days'])) ||
+ intval($rr['channel_expire_days'] == 0)) {
+ $expire_days = $channel_expire;
+ } else {
+ $expire_days = $rr['channel_expire_days'];
+ }
+
+ // if the site or service class expiration is non-zero and less than person expiration, use that
+ logger('Expire: ' . $rr['channel_address'] . ' interval: ' . $expire_days, LOGGER_DEBUG);
+ item_expire($rr['channel_id'], $expire_days);
}
}
-
$x = get_sys_channel();
- if($x) {
+ if ($x) {
// this should probably just fetch the channel_expire_days from the sys channel,
// but there's no convenient way to set it.
- $expire_days = get_config('externals','expire_days');
- if($expire_days === false)
+ $expire_days = get_config('system', 'sys_expire_days');
+ if ($expire_days === false)
$expire_days = 30;
- if($expire_days)
- item_expire($x['channel_id'],$expire_days);
- }
+ if (intval($site_expire) && (intval($site_expire) < intval($expire_days))) {
+ $expire_days = $site_expire;
+ }
- return;
+ logger('Expire: sys interval: ' . $expire_days, LOGGER_DEBUG);
+
+ if ($expire_days)
+ item_expire($x['channel_id'], $expire_days);
+
+ logger('Expire: sys: done', LOGGER_DEBUG);
+ }
}
-if (array_search(__file__,get_included_files())===0){
- expire_run($argv,$argc);
- killme();
+if (array_search(__file__, get_included_files()) === 0){
+ expire_run($argv, $argc);
+ killme();
}