aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon/Cron.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Daemon/Cron.php')
-rw-r--r--Zotlabs/Daemon/Cron.php58
1 files changed, 24 insertions, 34 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index d2c863572..131abe2e1 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -69,18 +69,18 @@ class Cron {
// expire any expired items
- $r = q("select id,item_wall from item where expires > '2001-01-01 00:00:00' and expires < %s
+ $r = q("select id, uid, item_wall from item where expires > '2001-01-01 00:00:00' and expires < %s
and item_deleted = 0 ",
db_utcnow()
);
+
if ($r) {
- require_once('include/items.php');
foreach ($r as $rr) {
- drop_item($rr['id'], false, (($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL));
+ // pass uid of the message for permission check as we are running as a daemon process with no session.
+ drop_item($rr['id'], (($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL), uid: intval($rr['uid']));
if ($rr['item_wall']) {
// The notifier isn't normally invoked unless item_drop is interactive.
Master::Summon(['Notifier', 'drop', $rr['id']]);
-
if ($interval) {
usleep($interval);
}
@@ -125,14 +125,15 @@ class Cron {
$r = q("SELECT DISTINCT xchan, content FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
intval(PHOTO_CACHE),
db_utcnow(),
- db_quoteinterval(Config::Get('system', 'cache_expire_days', 7) . ' DAY')
+ db_quoteinterval(Config::Get('system', 'default_expire_days', 30) . ' DAY')
);
if ($r) {
q("DELETE FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
intval(PHOTO_CACHE),
db_utcnow(),
- db_quoteinterval(Config::Get('system', 'cache_expire_days', 7) . ' DAY')
+ db_quoteinterval(Config::Get('system', 'default_expire_days', 30) . ' DAY')
);
+
foreach ($r as $rr) {
$file = dbunescbin($rr['content']);
if (is_file($file)) {
@@ -147,40 +148,29 @@ class Cron {
// (time travel posts). Restrict to items that have come of age in the last
// couple of days to limit the query to something reasonable.
- $r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ",
+ $r = q("select * from item where item_delayed = 1 and created <= %s and created > '%s' ",
db_utcnow(),
dbesc(datetime_convert('UTC', 'UTC', 'now - 2 days'))
);
- if ($r) {
- foreach ($r as $rr) {
- $x = q("update item set item_delayed = 0 where id = %d",
- intval($rr['id'])
- );
- if ($x) {
- $z = q("select * from item where id = %d",
- intval($rr['id'])
- );
- if ($z) {
- xchan_query($z);
- $sync_item = fetch_post_tags($z);
- Libsync::build_sync_packet($sync_item[0]['uid'],
- [
- 'item' => [encode_item($sync_item[0], true)]
- ]
- );
- }
- Master::Summon(array('Notifier', 'wall-new', $rr['id']));
- if ($interval) {
- usleep($interval);
+ if ($r) {
+ xchan_query($r);
+ $items = fetch_post_tags($r);
+ foreach ($items as $item) {
+ $item['item_delayed'] = 0;
+ $post = item_store_update($item);
+
+ if($post['success']) {
+ Master::Summon(['Notifier', 'wall-new', $post['item_id']]);
+ if (!empty($post['approval_id'])) {
+ Master::Summon(['Notifier', 'wall-new', $post['approval_id']]);
}
}
- }
- }
-
- require_once('include/attach.php');
- attach_upgrade();
-
+ if ($interval) {
+ usleep($interval);
+ }
+ }
+ }
// once daily run birthday_updates and then expire in background
// FIXME: add birthday updates, both locally and for xprof for use