From 581a3c532303c008390a2851a1e42c6f5de390b1 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 6 Jul 2016 22:02:06 -0700 Subject: expire crashing on shared hosting from memory exhaustion. Lower the expire limit. Also the sys channel was being expired with everybody else due to a flag change regression. --- Zotlabs/Daemon/Expire.php | 2 +- include/items.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 0ba83b240..215513e87 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -38,7 +38,7 @@ class Expire { logger('site_expire: ' . $site_expire); - $r = q("SELECT channel_id, channel_address, channel_pageflags, channel_expire_days from channel where true"); + $r = q("SELECT channel_id, channel_system, channel_address, channel_expire_days from channel where true"); if ($r) { foreach ($r as $rr) { diff --git a/include/items.php b/include/items.php index 48358c0e4..fd0cfff32 100755 --- a/include/items.php +++ b/include/items.php @@ -3282,7 +3282,7 @@ function item_expire($uid,$days) { $expire_limit = get_config('system','expire_limit'); if(! intval($expire_limit)) - $expire_limit = 5000; + $expire_limit = 2500; $item_normal = item_normal(); -- cgit v1.2.3 From 3bee6543fbd339adf9b9993269b6a46bec27f05e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 6 Jul 2016 22:19:05 -0700 Subject: reduce the memory usage of the expire query dramatically. --- include/items.php | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/include/items.php b/include/items.php index fd0cfff32..72f0896ad 100755 --- a/include/items.php +++ b/include/items.php @@ -3282,19 +3282,21 @@ function item_expire($uid,$days) { $expire_limit = get_config('system','expire_limit'); if(! intval($expire_limit)) - $expire_limit = 2500; + $expire_limit = 5000; $item_normal = item_normal(); - $r = q("SELECT * FROM `item` - WHERE `uid` = %d - AND `created` < %s - INTERVAL %s - AND `id` = `parent` - $sql_extra + $r = q("SELECT id FROM item + WHERE uid = %d + AND created < %s - INTERVAL %s AND item_retained = 0 - $item_normal LIMIT $expire_limit ", + AND item_thread_top = 1 + AND resource_type = '' + AND item_starred = 0 + $sql_extra $item_normal LIMIT $expire_limit ", intval($uid), - db_utcnow(), db_quoteinterval(intval($days).' DAY') + db_utcnow(), + db_quoteinterval(intval($days).' DAY') ); if(! $r) @@ -3312,17 +3314,6 @@ function item_expire($uid,$days) { continue; } - // Only expire posts, not photos and photo comments - - if($item['resource_type'] === 'photo') { - retain_item($item['id']); - continue; - } - if(intval($item['item_starred'])) { - retain_item($item['id']); - continue; - } - drop_item($item['id'],false); } -- cgit v1.2.3