X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fexpire.php;h=7a3549ada64dc7e160071c44221eb1e564670971;hb=f3c8af485f67eda7cefb602793b94aebc17ffeb1;hp=098125a79864efb3315fe75ebd2319b6eca5a0de;hpb=affb3938d2b3e81971b55e00613c4cd7fee513bd;p=friendica.git diff --git a/include/expire.php b/include/expire.php index 098125a798..7a3549ada6 100644 --- a/include/expire.php +++ b/include/expire.php @@ -1,6 +1,8 @@ $row['id'])); + } + dba::close($r); - // make this optional as it could have a performance impact on large sites + logger('Delete expired items - done', LOGGER_DEBUG); - if (intval(get_config('system','optimize_items'))) { - q("OPTIMIZE TABLE `item`"); + // make this optional as it could have a performance impact on large sites + if (intval(Config::get('system', 'optimize_items'))) { + q("OPTIMIZE TABLE `item`"); + } + return; + } elseif (($argc == 2) && (intval($argv[1]) > 0)) { + $user = dba::select('user', array('uid', 'username', 'expire'), array('uid' => $argv[1]), array('limit' => 1)); + if (DBM::is_result($user)) { + logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG); + item_expire($user['uid'], $user['expire']); + logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG); + } + return; + } elseif (($argc == 3) && ($argv[1] == 'hook') && is_array($a->hooks) && array_key_exists("expire", $a->hooks)) { + foreach ($a->hooks["expire"] as $hook) { + if ($hook[1] == $argv[2]) { + logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG); + call_single_hook($a, $name, $hook, $data); + } + } + return; } logger('expire: start'); - $r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0"); - if (dbm::is_result($r)) { - foreach ($r as $rr) { - logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG); - item_expire($rr['uid'],$rr['expire']); - } + Worker::add(array('priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true), + 'expire', 'delete'); + + $r = dba::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0"); + while ($row = dba::fetch($r)) { + logger('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG); + Worker::add(array('priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true), + 'expire', (int)$row['uid']); } + dba::close($r); - load_hooks(); + logger('expire: calling hooks'); + + if (is_array($a->hooks) && array_key_exists('expire', $a->hooks)) { + foreach ($a->hooks['expire'] as $hook) { + logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG); + Worker::add(array('priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true), + 'expire', 'hook', $hook[1]); + } + } - call_hooks('expire'); + logger('expire: end'); return; }