X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fcron.php;h=6afbeca1bd1bbc9dcb22ad1b84f86a0c8551c5b3;hb=497fd34026fbaa83b11a64d3a0a6e20f1360e5d6;hp=28d6713f5428a0018f1a0ff9009f5e6bce869101;hpb=b9dbb0ace1f80f51892b382f68f6441fb7d5c906;p=friendica.git diff --git a/include/cron.php b/include/cron.php index 28d6713f54..6afbeca1bd 100644 --- a/include/cron.php +++ b/include/cron.php @@ -80,42 +80,37 @@ function cron_run(&$argv, &$argc){ proc_run(PRIORITY_LOW,"include/discover_poco.php", "checkcontact"); - // expire any expired accounts - - q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 - AND `account_expires_on` != '0000-00-00 00:00:00' - AND `account_expires_on` < UTC_TIMESTAMP() "); + // Expire and remove user entries + cron_expire_and_remove_users(); - // delete user and contact records for recently removed accounts - - $r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); - if ($r) { - foreach($r as $user) { - q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid'])); - q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid'])); - } - } + // If the worker is active, split the jobs in several sub processes + if (get_config("system", "worker")) { + // Check OStatus conversations + proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions"); - $abandon_days = intval(get_config('system','account_abandon_days')); - if($abandon_days < 1) - $abandon_days = 0; + // Check every conversation + proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations"); - // Check OStatus conversations - // Check only conversations with mentions (for a longer time) - ostatus::check_conversations(true); + // Call possible post update functions + proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update"); - // Check every conversation - ostatus::check_conversations(false); + // update nodeinfo data + proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo"); + } else { + // Check OStatus conversations + // Check only conversations with mentions (for a longer time) + ostatus::check_conversations(true); - // Call possible post update functions - // see include/post_update.php for more details - post_update(); + // Check every conversation + ostatus::check_conversations(false); - // update nodeinfo data - nodeinfo_cron(); + // Call possible post update functions + // see include/post_update.php for more details + post_update(); - /// @TODO Regenerate usage statistics - // q("ANALYZE TABLE `item`"); + // update nodeinfo data + nodeinfo_cron(); + } // once daily run birthday_updates and then expire in background @@ -153,9 +148,29 @@ function cron_run(&$argv, &$argc){ } /** - * @brief Clear cache entries + * @brief Expire and remove user entries + */ +function cron_expire_and_remove_users() { + // expire any expired accounts + q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 + AND `account_expires_on` != '0000-00-00 00:00:00' + AND `account_expires_on` < UTC_TIMESTAMP() "); + + // delete user and contact records for recently removed accounts + $r = q("SELECT * FROM `user` WHERE `account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); + if ($r) { + foreach($r as $user) { + q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid'])); + q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid'])); + } + } +} + +/** + * @brief Poll contacts for unreceived messages * - * @param App $a + * @param Integer $argc Number of command line arguments + * @param Array $argv Array of command line arguments */ function cron_poll_contacts($argc, $argv) { $manual_id = 0; @@ -196,6 +211,10 @@ function cron_poll_contacts($argc, $argv) { // and which have a polling address and ignore Diaspora since // we are unable to match those posts with a Diaspora GUID and prevent duplicates. + $abandon_days = intval(get_config('system','account_abandon_days')); + if($abandon_days < 1) + $abandon_days = 0; + $abandon_sql = (($abandon_days) ? sprintf(" AND `user`.`login_date` > UTC_TIMESTAMP() - INTERVAL %d DAY ", intval($abandon_days)) : ''