From: Michael Date: Sun, 19 Nov 2017 16:25:13 +0000 (+0000) Subject: expire and gprobe now moved as well X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=501514bd5406253bcbcb420d89fa04199fe5b8c2;p=friendica.git expire and gprobe now moved as well --- diff --git a/include/expire.php b/include/expire.php deleted file mode 100644 index 7a3549ada6..0000000000 --- a/include/expire.php +++ /dev/null @@ -1,76 +0,0 @@ - $row['id'])); - } - dba::close($r); - - logger('Delete expired items - done', LOGGER_DEBUG); - - // 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'); - - 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); - - 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]); - } - } - - logger('expire: end'); - - return; -} diff --git a/include/gprobe.php b/include/gprobe.php deleted file mode 100644 index a6b46afc56..0000000000 --- a/include/gprobe.php +++ /dev/null @@ -1,64 +0,0 @@ - $tmp_str, 'url' => $a->cmd); call_hooks('zrl_init', $arr); } diff --git a/src/Model/GlobalContact.php b/src/Model/GlobalContact.php index 2e16c687f9..1ca814789b 100644 --- a/src/Model/GlobalContact.php +++ b/src/Model/GlobalContact.php @@ -688,7 +688,7 @@ class GlobalContact if ($doprobing) { logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG); - Worker::add(PRIORITY_LOW, 'gprobe', $contact["url"]); + Worker::add(PRIORITY_LOW, 'GProbe', $contact["url"]); } return $gcontact_id; diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index b3f0f1f691..429aed3d96 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -79,7 +79,7 @@ Class Cron { Config::set('system', 'last_expire_day', $d2); - Worker::add(PRIORITY_LOW, 'expire'); + Worker::add(PRIORITY_LOW, 'Expire'); Worker::add(PRIORITY_MEDIUM, 'DBClean'); diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php new file mode 100644 index 0000000000..ac2577e77e --- /dev/null +++ b/src/Worker/Expire.php @@ -0,0 +1,85 @@ + $row['id'])); + } + dba::close($r); + + logger('Delete expired items - done', LOGGER_DEBUG); + + // make this optional as it could have a performance impact on large sites + if (intval(Config::get('system', 'optimize_items'))) { + dba::e("OPTIMIZE TABLE `item`"); + } + return; + } elseif (intval($param) > 0) { + $user = dba::select('user', array('uid', 'username', 'expire'), array('uid' => $param), 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 (!empty($hook_name) && ($param == 'hook') && is_array($a->hooks) && array_key_exists("expire", $a->hooks)) { + foreach ($a->hooks["expire"] as $hook) { + if ($hook[1] == $hook_name) { + logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG); + call_single_hook($a, $name, $hook, $data); + } + } + return; + } + + logger('expire: start'); + + 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); + + 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]); + } + } + + logger('expire: end'); + + return; + } +} diff --git a/src/Worker/GProbe.php b/src/Worker/GProbe.php new file mode 100644 index 0000000000..bfe277fe09 --- /dev/null +++ b/src/Worker/GProbe.php @@ -0,0 +1,65 @@ +