]> git.mxchange.org Git - friendica.git/commitdiff
The priority is now a class constant
authorMichael <heluecht@pirati.ca>
Mon, 17 Oct 2022 05:49:55 +0000 (05:49 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 17 Oct 2022 05:49:55 +0000 (05:49 +0000)
46 files changed:
boot.php
mod/events.php
mod/item.php
mod/tagger.php
src/Console/Relocate.php
src/Core/Search.php
src/Core/Update.php
src/Core/UserImport.php
src/Core/Worker.php
src/Core/Worker/Cron.php
src/Model/Contact.php
src/Model/FContact.php
src/Model/GServer.php
src/Model/Item.php
src/Model/Mail.php
src/Model/Post/Delayed.php
src/Model/Profile.php
src/Model/PushSubscriber.php
src/Model/Subscription.php
src/Model/User.php
src/Module/Admin/Blocklist/Contact.php
src/Module/Admin/Blocklist/Server/Add.php
src/Module/Admin/Site.php
src/Module/Api/Friendica/Events/Create.php
src/Module/Api/Mastodon/Statuses.php
src/Module/Contact.php
src/Module/FriendSuggest.php
src/Module/Photo.php
src/Module/Register.php
src/Module/Settings/Account.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php
src/Protocol/Diaspora.php
src/Protocol/Feed.php
src/Worker/CheckDeletedContacts.php
src/Worker/Cron.php
src/Worker/Directory.php
src/Worker/ExpirePosts.php
src/Worker/MoveStorage.php
src/Worker/Notifier.php
src/Worker/PollContacts.php
src/Worker/RemoveUser.php
src/Worker/UpdateContacts.php
src/Worker/UpdateGServers.php
static/defaults.config.php
update.php

index 8e7958de36cd3919a6c42527aef3f657b25bc505..b90c1fb2e21f7e244ed24f3eae6ffbdc39652026 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -71,21 +71,6 @@ define('GRAVITY_COMMENT',      6);
 define('GRAVITY_UNKNOWN',      9);
 /* @}*/
 
-/**
- * @name Priority
- *
- * Process priority for the worker
- * @{
- */
-define('PRIORITY_UNDEFINED',   0);
-define('PRIORITY_CRITICAL',   10);
-define('PRIORITY_HIGH',       20);
-define('PRIORITY_MEDIUM',     30);
-define('PRIORITY_LOW',        40);
-define('PRIORITY_NEGLIGIBLE', 50);
-define('PRIORITIES', [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE]);
-/* @}*/
-
 // Normally this constant is defined - but not if "pcntl" isn't installed
 if (!defined('SIGTERM')) {
        define('SIGTERM', 15);
index 082cdf55dd7ca5401b2bc9ae4c956c1ec0a365e1..eead66c01022dba9a20ec70b2de6d2e8c732a2b3 100644 (file)
@@ -205,7 +205,7 @@ function events_post(App $a)
        }
 
        if (!$cid && $uri_id) {
-               Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$uri_id, (int)$uid);
+               Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$uri_id, (int)$uid);
        }
 
        DI::baseUrl()->redirect('events');
index f3f0fd40d6b05a16b7dc0cc7ec6370530f328000..8f4494ca72f6dd7908bdb3bf740e27eaf585a564 100644 (file)
@@ -36,6 +36,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Session;
 use Friendica\Core\System;
+use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Attach;
@@ -635,7 +636,7 @@ function item_post(App $a) {
                        unset($datarray['self']);
                        unset($datarray['api_source']);
 
-                       Post\Delayed::add($datarray['uri'], $datarray, PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
+                       Post\Delayed::add($datarray['uri'], $datarray, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED_NO_HOOK, $scheduled_at);
                        item_post_return(DI::baseUrl(), $api_source, $return_path);
                }
        }
index e0d95ce662ff4fe928b8ae37d1010b3724c21581..45b743166c798a0ba4389ad3dd80d72fbb810fe1 100644 (file)
@@ -166,6 +166,6 @@ EOT;
 
        $post = Post::selectFirst(['uri-id', 'uid'], ['id' => $post_id]);
 
-       Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
+       Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, $post['uri-id'], $post['uid']);
        System::exit();
 }
index c1db6ef534c604f42f70c07c11522b67b48418ac..729bee392f4ea5bd33ec651989ac6a78868fb887 100644 (file)
@@ -197,7 +197,7 @@ HELP;
                $this->out('Schedule relocation messages to remote Friendica and Diaspora hosts');
                $users = $this->database->selectToArray('user', ['uid'], ['account_removed' => false, 'account_expired' => false]);
                foreach ($users as $user) {
-                       Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
+                       Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
                }
 
                return 0;
index 5ae1dd7ac4a9c0aecc1fcd6b590c161770722a71..cf3821afcf662ceee532e4c6bf4984c06c1fae8e 100644 (file)
@@ -192,7 +192,7 @@ class Search
                }
 
                // Add found profiles from the global directory to the local directory
-               Worker::add(PRIORITY_LOW, 'SearchDirectory', $search);
+               Worker::add(Worker::PRIORITY_LOW, 'SearchDirectory', $search);
 
                return $resultList;
        }
index ddb9effd713f583e425bf8aa1edc97694c1d8863..ad5b317600aa8ee148e5bea68252bca531a1c579 100644 (file)
@@ -92,7 +92,7 @@ class Update
                                 */
                                self::run($basePath);
                        } else {
-                               Worker::add(PRIORITY_CRITICAL, 'DBUpdate');
+                               Worker::add(Worker::PRIORITY_CRITICAL, 'DBUpdate');
                        }
                }
        }
index 339ce0b65b0aaac1a7b33fc45ec43f47523a012d..f8485fc293e08cc9a1a4d6c13ecf8eb01442899b 100644 (file)
@@ -322,7 +322,7 @@ class UserImport
                }
 
                // send relocate messages
-               Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid);
+               Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid);
 
                info(DI::l10n()->t("Done. You can now login with your username and password"));
                DI::baseUrl()->redirect('login');
index a57792ce7cee881d92ebf75c60a8882ae491c3d2..9ec2f8f04aba814588af9212607705c1025088a9 100644 (file)
@@ -31,12 +31,20 @@ use Friendica\Util\DateTimeFormat;
  */
 class Worker
 {
-       const PRIORITY_UNDEFINED  = PRIORITY_UNDEFINED;
-       const PRIORITY_CRITICAL   = PRIORITY_CRITICAL;
-       const PRIORITY_HIGH       = PRIORITY_HIGH;
-       const PRIORITY_MEDIUM     = PRIORITY_MEDIUM;
-       const PRIORITY_LOW        = PRIORITY_LOW;
-       const PRIORITY_NEGLIGIBLE = PRIORITY_NEGLIGIBLE;
+       /**
+        * @name Priority
+        *
+        * Process priority for the worker
+        * @{
+        */
+       const PRIORITY_UNDEFINED  = 0;
+       const PRIORITY_CRITICAL   = 10;
+       const PRIORITY_HIGH       = 20;
+       const PRIORITY_MEDIUM     = 30;
+       const PRIORITY_LOW        = 40;
+       const PRIORITY_NEGLIGIBLE = 50;
+       const PRIORITIES          = [self::PRIORITY_CRITICAL, self::PRIORITY_HIGH, self::PRIORITY_MEDIUM, self::PRIORITY_LOW, self::PRIORITY_NEGLIGIBLE];
+       /* @}*/
 
        const STATE_STARTUP    = 1; // Worker is in startup. This takes most time.
        const STATE_LONG_LOOP  = 2; // Worker is processing the whole - long - loop.
@@ -807,7 +815,7 @@ class Worker
                                $top_priority = self::highestPriority();
                                $high_running = self::processWithPriorityActive($top_priority);
 
-                               if (!$high_running && ($top_priority > PRIORITY_UNDEFINED) && ($top_priority < PRIORITY_NEGLIGIBLE)) {
+                               if (!$high_running && ($top_priority > self::PRIORITY_UNDEFINED) && ($top_priority < self::PRIORITY_NEGLIGIBLE)) {
                                        Logger::info('Jobs with a higher priority are waiting but none is executed. Open a fastlane.', ['priority' => $top_priority]);
                                        $queues = $active + 1;
                                }
@@ -939,7 +947,7 @@ class Worker
        private static function nextPriority()
        {
                $waiting = [];
-               $priorities = [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE];
+               $priorities = [self::PRIORITY_CRITICAL, self::PRIORITY_HIGH, self::PRIORITY_MEDIUM, self::PRIORITY_LOW, self::PRIORITY_NEGLIGIBLE];
                foreach ($priorities as $priority) {
                        $stamp = (float)microtime(true);
                        if (DBA::exists('workerqueue', ["`priority` = ? AND `pid` = 0 AND NOT `done` AND `next_try` < ?", $priority, DateTimeFormat::utcNow()])) {
@@ -948,8 +956,8 @@ class Worker
                        self::$db_duration += (microtime(true) - $stamp);
                }
 
-               if (!empty($waiting[PRIORITY_CRITICAL])) {
-                       return PRIORITY_CRITICAL;
+               if (!empty($waiting[self::PRIORITY_CRITICAL])) {
+                       return self::PRIORITY_CRITICAL;
                }
 
                $running = [];
@@ -1206,8 +1214,8 @@ class Worker
         * @param (integer|array) priority or parameter array, strings are deprecated and are ignored
         *
         * next args are passed as $cmd command line
-        * or: Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::DELETION, $drop_id);
-        * or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), 'Delivery', $post_id);
+        * or: Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::DELETION, $drop_id);
+        * or: Worker::add(array('priority' => Worker::PRIORITY_HIGH, 'dont_fork' => true), 'Delivery', $post_id);
         *
         * @return int '0' if worker queue entry already existed or there had been an error, otherwise the ID of the worker task
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
@@ -1230,7 +1238,7 @@ class Worker
                        return 1;
                }
 
-               $priority = PRIORITY_MEDIUM;
+               $priority = self::PRIORITY_MEDIUM;
                // Don't fork from frontend tasks by default
                $dont_fork = DI::config()->get('system', 'worker_dont_fork', false) || !DI::mode()->isBackend();
                $created = DateTimeFormat::utcNow();
@@ -1266,9 +1274,9 @@ class Worker
                $found = DBA::exists('workerqueue', ['command' => $command, 'parameter' => $parameters, 'done' => false]);
                $added = 0;
 
-               if (!is_int($priority) || !in_array($priority, PRIORITIES)) {
+               if (!is_int($priority) || !in_array($priority, self::PRIORITIES)) {
                        Logger::warning('Invalid priority', ['priority' => $priority, 'command' => $command, 'callstack' => System::callstack(20)]);
-                       $priority = PRIORITY_MEDIUM;
+                       $priority = self::PRIORITY_MEDIUM;
                }
 
                // Quit if there was a database error - a precaution for the update process to 3.5.3
@@ -1383,12 +1391,12 @@ class Worker
                $delay = (($new_retrial + 2) ** 4) + (rand(1, 30) * ($new_retrial));
                $next = DateTimeFormat::utc('now + ' . $delay . ' seconds');
 
-               if (($priority < PRIORITY_MEDIUM) && ($new_retrial > 3)) {
-                       $priority = PRIORITY_MEDIUM;
-               } elseif (($priority < PRIORITY_LOW) && ($new_retrial > 6)) {
-                       $priority = PRIORITY_LOW;
-               } elseif (($priority < PRIORITY_NEGLIGIBLE) && ($new_retrial > 8)) {
-                       $priority = PRIORITY_NEGLIGIBLE;
+               if (($priority < self::PRIORITY_MEDIUM) && ($new_retrial > 3)) {
+                       $priority = self::PRIORITY_MEDIUM;
+               } elseif (($priority < self::PRIORITY_LOW) && ($new_retrial > 6)) {
+                       $priority = self::PRIORITY_LOW;
+               } elseif (($priority < self::PRIORITY_NEGLIGIBLE) && ($new_retrial > 8)) {
+                       $priority = self::PRIORITY_NEGLIGIBLE;
                }
 
                Logger::info('Deferred task', ['id' => $id, 'retrial' => $new_retrial, 'created' => $queue['created'], 'next_execution' => $next, 'old_prio' => $queue['priority'], 'new_prio' => $priority]);
index 0f2c4b41e7157e24e926f909a1517f4e83b40a92..11631e02b341e4594bd6774d1919c446aa4914d0 100644 (file)
@@ -47,10 +47,10 @@ class Cron
                Logger::info('Add cron entries');
 
                // Check for spooled items
-               Worker::add(['priority' => PRIORITY_HIGH, 'force_priority' => true], 'SpoolPost');
+               Worker::add(['priority' => Worker::PRIORITY_HIGH, 'force_priority' => true], 'SpoolPost');
 
                // Run the cron job that calls all other jobs
-               Worker::add(['priority' => PRIORITY_MEDIUM, 'force_priority' => true], 'Cron');
+               Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'Cron');
 
                // Cleaning dead processes
                self::killStaleWorkers();
@@ -112,12 +112,12 @@ class Cron
                                        // To avoid a blocking situation we reschedule the process at the beginning of the queue.
                                        // Additionally we are lowering the priority. (But not PRIORITY_CRITICAL)
                                        $new_priority = $entry['priority'];
-                                       if ($entry['priority'] == PRIORITY_HIGH) {
-                                               $new_priority = PRIORITY_MEDIUM;
-                                       } elseif ($entry['priority'] == PRIORITY_MEDIUM) {
-                                               $new_priority = PRIORITY_LOW;
-                                       } elseif ($entry['priority'] != PRIORITY_CRITICAL) {
-                                               $new_priority = PRIORITY_NEGLIGIBLE;
+                                       if ($entry['priority'] == Worker::PRIORITY_HIGH) {
+                                               $new_priority = Worker::PRIORITY_MEDIUM;
+                                       } elseif ($entry['priority'] == Worker::PRIORITY_MEDIUM) {
+                                               $new_priority = Worker::PRIORITY_LOW;
+                                       } elseif ($entry['priority'] != Worker::PRIORITY_CRITICAL) {
+                                               $new_priority = Worker::PRIORITY_NEGLIGIBLE;
                                        }
                                        DBA::update('workerqueue', ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0], ['id' => $entry["id"]]
                                        );
@@ -166,13 +166,13 @@ class Cron
                                Logger::info('Directly deliver inbox', ['inbox' => $delivery['inbox'], 'result' => $result['success']]);
                                continue;
                        } elseif ($delivery['failed'] < 3) {
-                               $priority = PRIORITY_HIGH;
+                               $priority = Worker::PRIORITY_HIGH;
                        } elseif ($delivery['failed'] < 6) {
-                               $priority = PRIORITY_MEDIUM;
+                               $priority = Worker::PRIORITY_MEDIUM;
                        } elseif ($delivery['failed'] < 8) {
-                               $priority = PRIORITY_LOW;
+                               $priority = Worker::PRIORITY_LOW;
                        } else {
-                               $priority = PRIORITY_NEGLIGIBLE;
+                               $priority = Worker::PRIORITY_NEGLIGIBLE;
                        }
 
                        if ($delivery['failed'] >= DI::config()->get('system', 'worker_defer_limit')) {
index ceaf635df149e0288f57dc15071ce40a4d829286..434c2b1f637e6375e7f962890b1a05b4fa0da4fd 100644 (file)
@@ -319,7 +319,7 @@ class Contact
 
                // Update the contact in the background if needed
                if (Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
-                       Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
+                       Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
                }
 
                // Remove the internal fields
@@ -884,7 +884,7 @@ class Contact
                }
 
                // Delete it in the background
-               Worker::add(PRIORITY_MEDIUM, 'Contact\Remove', $id);
+               Worker::add(Worker::PRIORITY_MEDIUM, 'Contact\Remove', $id);
        }
 
        /**
@@ -908,7 +908,7 @@ class Contact
                if (in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
                        $cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
                        if (!empty($cdata['public'])) {
-                               Worker::add(PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
+                               Worker::add(Worker::PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
                        }
                }
 
@@ -938,7 +938,7 @@ class Contact
                if (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND])) {
                        $cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
                        if (!empty($cdata['public'])) {
-                               Worker::add(PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
+                               Worker::add(Worker::PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
                        }
                }
 
@@ -966,11 +966,11 @@ class Contact
                $cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
 
                if (in_array($contact['rel'], [self::SHARING, self::FRIEND]) && !empty($cdata['public'])) {
-                       Worker::add(PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
+                       Worker::add(Worker::PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
                }
 
                if (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND]) && !empty($cdata['public'])) {
-                       Worker::add(PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
+                       Worker::add(Worker::PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
                }
 
                self::remove($contact['id']);
@@ -1248,7 +1248,7 @@ class Contact
                        $contact_id = $contact['id'];
 
                        if (Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
-                               Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
+                               Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
                        }
 
                        if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) {
@@ -2365,7 +2365,7 @@ class Contact
                                return;
                        }
                        Logger::warning('account-user exists for a different contact id', ['account_user' => $account_user, 'id' => $id, 'uid' => $uid, 'uri-id' => $uri_id, 'url' => $url]);
-                       Worker::add(PRIORITY_HIGH, 'MergeContact', $account_user['id'], $id, $uid);
+                       Worker::add(Worker::PRIORITY_HIGH, 'MergeContact', $account_user['id'], $id, $uid);
                } elseif (DBA::insert('account-user', ['id' => $id, 'uri-id' => $uri_id, 'uid' => $uid], Database::INSERT_IGNORE)) {
                        Logger::notice('account-user was added', ['id' => $id, 'uid' => $uid, 'uri-id' => $uri_id, 'url' => $url]);
                } else {
@@ -2406,7 +2406,7 @@ class Contact
                                continue;
                        }
 
-                       Worker::add(PRIORITY_HIGH, 'MergeContact', $first, $duplicate['id'], $uid);
+                       Worker::add(Worker::PRIORITY_HIGH, 'MergeContact', $first, $duplicate['id'], $uid);
                }
                DBA::close($duplicates);
                Logger::info('Duplicates handled', ['uid' => $uid, 'nurl' => $nurl, 'callstack' => System::callstack(20)]);
@@ -2608,7 +2608,7 @@ class Contact
                        if ($ret['network'] == Protocol::ACTIVITYPUB) {
                                $apcontact = APContact::getByURL($ret['url'], false);
                                if (!empty($apcontact['featured'])) {
-                                       Worker::add(PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
+                                       Worker::add(Worker::PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
                                }
                        }
 
@@ -2649,7 +2649,7 @@ class Contact
                        self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => false, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $success_next_update, 'success_update' => $updated]);
 
                        if (Contact\Relation::isDiscoverable($ret['url'])) {
-                               Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
+                               Worker::add(Worker::PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
                        }
 
                        // Update the public contact
@@ -2693,7 +2693,7 @@ class Contact
                self::updateContact($id, $uid, $ret['uri-id'], $ret['url'], $ret);
 
                if (Contact\Relation::isDiscoverable($ret['url'])) {
-                       Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
+                       Worker::add(Worker::PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
                }
 
                return true;
@@ -2949,13 +2949,13 @@ class Contact
 
                // pull feed and consume it, which should subscribe to the hub.
                if ($contact['network'] == Protocol::OSTATUS) {
-                       Worker::add(PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
+                       Worker::add(Worker::PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
                }
 
                if ($probed) {
                        self::updateFromProbeArray($contact_id, $ret);
                } else {
-                       Worker::add(PRIORITY_HIGH, 'UpdateContact', $contact_id);
+                       Worker::add(Worker::PRIORITY_HIGH, 'UpdateContact', $contact_id);
                }
 
                $result['success'] = Protocol::follow($uid, $contact, $protocol);
@@ -3407,10 +3407,10 @@ class Contact
                        }
                        $contact = self::getByURL($url, false, ['id', 'network', 'next-update']);
                        if (empty($contact['id']) && Network::isValidHttpUrl($url)) {
-                               Worker::add(PRIORITY_LOW, 'AddContact', 0, $url);
+                               Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url);
                                ++$added;
                        } elseif (!empty($contact['network']) && Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
-                               Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
+                               Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
                                ++$updated;
                        } else {
                                ++$unchanged;
index ae6c9cb316a76c7426bcf513aa5d9cbc60c23f2f..fa21906bc57076a577fa706c44164790598e1511 100644 (file)
@@ -58,7 +58,7 @@ class FContact
                                $update = empty($person['guid']) || empty($person['uri-id']) || ($person['created'] <= DBA::NULL_DATETIME);
                                if (GServer::getNextUpdateDate(true, $person['created'], $person['updated'], false) < DateTimeFormat::utcNow()) {
                                        Logger::debug('Start background update', ['handle' => $handle]);
-                                       Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateFContact', $handle);
+                                       Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateFContact', $handle);
                                }
                        }
                } elseif (is_null($update)) {
index ac8a843274ff0c78db89275dcd2b103feadab935..7e4b055d10900981cde793fad20b5f0f6c038d10 100644 (file)
@@ -102,7 +102,7 @@ class GServer
                        return;
                }
 
-               Worker::add(PRIORITY_LOW, 'UpdateGServer', $url, $only_nodeinfo);
+               Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $url, $only_nodeinfo);
        }
 
        /**
@@ -2108,10 +2108,10 @@ class GServer
 
                while ($gserver = DBA::fetch($gservers)) {
                        Logger::info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
-                       Worker::add(PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
+                       Worker::add(Worker::PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
 
                        Logger::info('Update directory', ['server' => $gserver['url'], 'id' => $gserver['id']]);
-                       Worker::add(PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
+                       Worker::add(Worker::PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
 
                        $fields = ['last_poco_query' => DateTimeFormat::utcNow()];
                        self::update($fields, ['nurl' => $gserver['nurl']]);
index 3270d170b676ea431650c57323a949327c075fa8..130a1c463de0123645466104a11d423c9b30ee10 100644 (file)
@@ -232,7 +232,7 @@ class Item
 
                foreach ($notify_items as $notify_item) {
                        $post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]);
-                       Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
+                       Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
                }
 
                return $rows;
@@ -246,7 +246,7 @@ class Item
         * @return void
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function markForDeletion(array $condition, int $priority = PRIORITY_HIGH)
+       public static function markForDeletion(array $condition, int $priority = Worker::PRIORITY_HIGH)
        {
                $items = Post::select(['id'], $condition);
                while ($item = Post::fetch($items)) {
@@ -277,7 +277,7 @@ class Item
                        }
 
                        if ($item['uid'] == $uid) {
-                               self::markForDeletionById($item['id'], PRIORITY_HIGH);
+                               self::markForDeletionById($item['id'], Worker::PRIORITY_HIGH);
                        } elseif ($item['uid'] != 0) {
                                Logger::warning('Wrong ownership. Not deleting item', ['id' => $item['id']]);
                        }
@@ -293,7 +293,7 @@ class Item
         * @return boolean success
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function markForDeletionById(int $item_id, int $priority = PRIORITY_HIGH): bool
+       public static function markForDeletionById(int $item_id, int $priority = Worker::PRIORITY_HIGH): bool
        {
                Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
                // locate item to be deleted
@@ -816,7 +816,7 @@ class Item
        {
                $orig_item = $item;
 
-               $priority = PRIORITY_HIGH;
+               $priority = Worker::PRIORITY_HIGH;
 
                // If it is a posting where users should get notifications, then define it as wall posting
                if ($notify) {
@@ -826,7 +826,7 @@ class Item
                        $item['protocol'] = Conversation::PARCEL_DIRECT;
                        $item['direction'] = Conversation::PUSH;
 
-                       if (is_int($notify) && in_array($notify, PRIORITIES)) {
+                       if (is_int($notify) && in_array($notify, Worker::PRIORITIES)) {
                                $priority = $notify;
                        }
                } else {
index e494119cb8d9731b26114a931643d6b09af22629..cdcd2258c10fcda9556ce3a2b9de2b33b76fe618 100644 (file)
@@ -239,7 +239,7 @@ class Mail
                }
 
                if ($post_id) {
-                       Worker::add(PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
+                       Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
                        return intval($post_id);
                } else {
                        return -3;
index 1f15f26b972ad81d6bd1e6e078b566ea96d55188..3f96af6984bff4092ec360be0418c31ad09d435e 100644 (file)
@@ -80,7 +80,7 @@ class Delayed
 
                Logger::notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]);
 
-               $wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
+               $wid = Worker::add(['priority' => Worker::PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
                if (!$wid) {
                        return 0;
                }
index 094df729e79d3cc79266cfca91cdad5ef06579bc..f6d189a103e50dffb8e3aa35be40f8fd8b7042bf 100644 (file)
@@ -153,11 +153,11 @@ class Profile
                if ($owner['net-publish'] || $force) {
                        // Update global directory in background
                        if (Search::getGlobalDirectory()) {
-                               Worker::add(PRIORITY_LOW, 'Directory', $owner['url']);
+                               Worker::add(Worker::PRIORITY_LOW, 'Directory', $owner['url']);
                        }
                }
 
-               Worker::add(PRIORITY_LOW, 'ProfileUpdate', $uid);
+               Worker::add(Worker::PRIORITY_LOW, 'ProfileUpdate', $uid);
        }
 
        /**
index 8aa67eee5f9004aa964ab4f3bb7430968347a807..5b6c8813a8d733602b8e3d5edc5b76febd992ca1 100644 (file)
@@ -37,7 +37,7 @@ class PushSubscriber
         * @return void
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function publishFeed(int $uid, int $default_priority = PRIORITY_HIGH)
+       public static function publishFeed(int $uid, int $default_priority = Worker::PRIORITY_HIGH)
        {
                $condition = ['push' => 0, 'uid' => $uid];
                DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition);
@@ -52,7 +52,7 @@ class PushSubscriber
         * @return void
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function requeue(int $default_priority = PRIORITY_HIGH)
+       public static function requeue(int $default_priority = Worker::PRIORITY_HIGH)
        {
                // We'll push to each subscriber that has push > 0,
                // i.e. there has been an update (set in notifier.php).
@@ -61,7 +61,7 @@ class PushSubscriber
                while ($subscriber = DBA::fetch($subscribers)) {
                        // We always handle retries with low priority
                        if ($subscriber['push'] > 1) {
-                               $priority = PRIORITY_LOW;
+                               $priority = Worker::PRIORITY_LOW;
                        } else {
                                $priority = $default_priority;
                        }
index 26617f941a3f4ad6ba48c64e04ce5331204fed1e..2796b37a0fe50a897059109ed60390773ad53daf 100644 (file)
@@ -152,7 +152,7 @@ class Subscription
                $subscriptions = DBA::select('subscription', [], ['uid' => $notification->uid, $type => true]);
                while ($subscription = DBA::fetch($subscriptions)) {
                        Logger::info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
-                       Worker::add(PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
+                       Worker::add(Worker::PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
                }
                DBA::close($subscriptions);
        }
index 574830603e816395364903e16db9c68b9fef18fc..5bd84466f8b9cc12cd6f6da20272f1c92d29fae2 100644 (file)
@@ -1317,7 +1317,7 @@ class User
 
                if (DBA::isResult($profile) && $profile['net-publish'] && Search::getGlobalDirectory()) {
                        $url = DI::baseUrl() . '/profile/' . $user['nickname'];
-                       Worker::add(PRIORITY_LOW, "Directory", $url);
+                       Worker::add(Worker::PRIORITY_LOW, "Directory", $url);
                }
 
                $l10n = DI::l10n()->withLang($register['language']);
@@ -1567,14 +1567,14 @@ class User
 
                // The user and related data will be deleted in Friendica\Worker\ExpireAndRemoveUsers
                DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc('now + 7 day')], ['uid' => $uid]);
-               Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
+               Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
 
                // Send an update to the directory
                $self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
-               Worker::add(PRIORITY_LOW, 'Directory', $self['url']);
+               Worker::add(Worker::PRIORITY_LOW, 'Directory', $self['url']);
 
                // Remove the user relevant data
-               Worker::add(PRIORITY_NEGLIGIBLE, 'RemoveUser', $uid);
+               Worker::add(Worker::PRIORITY_NEGLIGIBLE, 'RemoveUser', $uid);
 
                return true;
        }
index ac1406c7fe5e3d75db8c9c7774b8362c773ce9e1..35a8a151d53be12a499a674412f144e7e68109f5 100644 (file)
@@ -59,7 +59,7 @@ class Contact extends BaseAdmin
 
                        if ($block_purge) {
                                foreach (Model\Contact::selectToArray(['id'], ['nurl' => $contact['nurl']]) as $contact) {
-                                       Worker::add(PRIORITY_LOW, 'Contact\RemoveContent', $contact['id']);
+                                       Worker::add(Worker::PRIORITY_LOW, 'Contact\RemoveContent', $contact['id']);
                                }
                        }
 
index a4aaa4b65cb7fe8a7d4478b96c0fbe2f95014a6d..f060bcd060e97bac94b86fad47a208bf891f2610 100644 (file)
@@ -82,7 +82,7 @@ class Add extends BaseAdmin
                if (!empty($request['purge'])) {
                        $gservers = GServer::listByDomainPattern($pattern);
                        foreach (Contact::selectToArray(['id'], ['gsid' => array_column($gservers, 'id')]) as $contact) {
-                               Worker::add(PRIORITY_LOW, 'Contact\RemoveContent', $contact['id']);
+                               Worker::add(Worker::PRIORITY_LOW, 'Contact\RemoveContent', $contact['id']);
                        }
 
                        $this->sysmsg->addInfo($this->l10n->tt('%s server scheduled to be purged.', '%s servers scheduled to be purged.', count($gservers)));
index fbebfcb3fe6da80830ce3aa89aa7a522a68dc18e..37d8ed040fdd5e8716fbdfaaaf16e5e5270889ea 100644 (file)
@@ -53,7 +53,7 @@ class Site extends BaseAdmin
                $a = DI::app();
 
                if (!empty($_POST['republish_directory'])) {
-                       Worker::add(PRIORITY_LOW, 'Directory');
+                       Worker::add(Worker::PRIORITY_LOW, 'Directory');
                        return;
                }
 
@@ -150,7 +150,7 @@ class Site extends BaseAdmin
                // Has the directory url changed? If yes, then resubmit the existing profiles there
                if ($global_directory != DI::config()->get('system', 'directory') && ($global_directory != '')) {
                        DI::config()->set('system', 'directory', $global_directory);
-                       Worker::add(PRIORITY_LOW, 'Directory');
+                       Worker::add(Worker::PRIORITY_LOW, 'Directory');
                }
 
                if (DI::baseUrl()->getUrlPath() != "") {
index 8a8f13b501e457eebc1f2357968e64d0fb8e2c90..8c6ec8f63583cdc900a6630b8b06324f918bebfa 100644 (file)
@@ -104,7 +104,7 @@ class Create extends BaseApi
                        $item = ['network' => Protocol::DFRN, 'protocol' => Conversation::PARCEL_DIRECT, 'direction' => Conversation::PUSH];
                        $item = Event::getItemArrayForId($event_id, $item);
                        if (Item::insert($item)) {
-                               Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$item['uri-id'], $uid);
+                               Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$item['uri-id'], $uid);
                        }
                }
 
index 4a8c98697d42d8bb27b9c32c77dce66443d6b463..8cc3e3ddf2a53af8fbe8e24aeebcd52d2296d246 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\App\Router;
 use Friendica\Content\Text\Markdown;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
+use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -204,7 +205,7 @@ class Statuses extends BaseApi
                if (!empty($request['scheduled_at'])) {
                        $item['guid'] = Item::guid($item, true);
                        $item['uri'] = Item::newURI($item['guid']);
-                       $id = Post\Delayed::add($item['uri'], $item, PRIORITY_HIGH, Post\Delayed::PREPARED, $request['scheduled_at']);
+                       $id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, $request['scheduled_at']);
                        if (empty($id)) {
                                DI::mstdnError()->InternalError();
                        }
index 9c073b3ef1a892a15b06951eb0fb58107a5338e5..4f565a87176d7448a2ae9e9f32207ceea1bf1cbf 100644 (file)
@@ -126,9 +126,9 @@ class Contact extends BaseModule
                        }
 
                        // pull feed and consume it, which should subscribe to the hub.
-                       Worker::add(PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
+                       Worker::add(Worker::PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
                } else {
-                       Worker::add(PRIORITY_HIGH, 'UpdateContact', $contact_id);
+                       Worker::add(Worker::PRIORITY_HIGH, 'UpdateContact', $contact_id);
                }
        }
 
index 3cebd72cea580a01607e00fb199c200b21a281a2..d8a42d8de9f1da127bf07adc37adcd8f34bb5e18 100644 (file)
@@ -94,7 +94,7 @@ class FriendSuggest extends BaseModule
                        $note
                ));
 
-               Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
+               Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
 
                info($this->t('Friend suggestion sent.'));
        }
index 076dc8107afc7dee4e68221207dc03a688597fd2..5fdabd33c56757cb45a24e6337bb88916949179a 100644 (file)
@@ -338,7 +338,7 @@ class Photo extends BaseModule
                                                }
                                                if ($update) {
                                                        Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
-                                                       Worker::add(PRIORITY_LOW, 'UpdateContact', $id);
+                                                       Worker::add(Worker::PRIORITY_LOW, 'UpdateContact', $id);
                                                } else {
                                                        Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
                                                }
index 9c09baef82d937f76dc993a027dd35ef1cfe4062..95cea145881925f93c5275e821ca7db75e9afa27 100644 (file)
@@ -302,7 +302,7 @@ class Register extends BaseModule
 
                if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
                        $url = $base_url . '/profile/' . $user['nickname'];
-                       Worker::add(PRIORITY_LOW, 'Directory', $url);
+                       Worker::add(Worker::PRIORITY_LOW, 'Directory', $url);
                }
 
                if ($additional_account) {
index 373f1614d73ff06b6b842cfb4158bc62656a8164..62ad08a4c82aacd67b7d529a0dfc137b79f6e0f8 100644 (file)
@@ -375,7 +375,7 @@ class Account extends BaseSettings
                                                // "http" or "@" to be present in the string.
                                                // All other fields from the row will be ignored
                                                if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) {
-                                                       Worker::add(PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
+                                                       Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
                                                } else {
                                                        Logger::notice('Invalid account', ['url' => $csvRow[0]]);
                                                }
@@ -394,7 +394,7 @@ class Account extends BaseSettings
                }
 
                if (!empty($request['relocate-submit'])) {
-                       Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
+                       Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
                        info(DI::l10n()->t("Relocate message has been send to your contacts"));
                        DI::baseUrl()->redirect($redirectUrl);
                }
index 04ea02f80198df3aaaad8416bea77f0219e7a9e6..bb4d61b5af6777ac010655b1a2a8beaffa44ce8e 100644 (file)
@@ -552,7 +552,7 @@ class Processor
                        Logger::notice('Fetching is done by worker.', ['parent' => $activity['reply-to-id'], 'recursion-depth' => $recursion_depth]);
                        Fetch::add($activity['reply-to-id']);
                        $activity['recursion-depth'] = 0;
-                       $wid = Worker::add(PRIORITY_HIGH, 'FetchMissingActivity', $activity['reply-to-id'], $activity, '', Receiver::COMPLETION_AUTO);
+                       $wid = Worker::add(Worker::PRIORITY_HIGH, 'FetchMissingActivity', $activity['reply-to-id'], $activity, '', Receiver::COMPLETION_AUTO);
                        Fetch::setWorkerId($activity['reply-to-id'], $wid);
                } else {
                        Logger::debug('Activity will already be fetched via a worker.', ['url' => $activity['reply-to-id']]);
@@ -1665,9 +1665,9 @@ class Processor
                        }
                        if (DI::config()->get('system', 'bulk_delivery')) {
                                Post\Delivery::add($post['uri-id'], $uid, $inbox, $post['created'], Delivery::POST, [$cid]);
-                               Worker::add(PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
+                               Worker::add(Worker::PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
                        } else {
-                               Worker::add(PRIORITY_HIGH, 'APDelivery', Delivery::POST, $post['id'], $inbox, $uid, [$cid], $post['uri-id']);
+                               Worker::add(Worker::PRIORITY_HIGH, 'APDelivery', Delivery::POST, $post['id'], $inbox, $uid, [$cid], $post['uri-id']);
                        }
                }
        }
index 30348c7adeb1142feba3bac60394634b8a7441f1..1ecfaf6aa4cc7ff1e96706e9059cb21d119dfc0a 100644 (file)
@@ -652,7 +652,7 @@ class Receiver
                                // We delay by 5 seconds to allow to accumulate all receivers
                                $delayed = date(DateTimeFormat::MYSQL, time() + 5);
                                Logger::debug('Initiate processing', ['id' => $object_data['entry-id'], 'uri' => $object_data['object_id']]);
-                               $wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'ProcessQueue', $object_data['entry-id']);
+                               $wid = Worker::add(['priority' => Worker::PRIORITY_HIGH, 'delayed' => $delayed], 'ProcessQueue', $object_data['entry-id']);
                                Queue::setWorkerId($object_data['entry-id'], $wid);
                        } else {
                                Logger::debug('Other queue entries need to be processed first.', ['id' => $object_data['entry-id']]);
index 66ace1d3db448dbb09cb496dc15d955fd41c2fb3..a2c17f4788c56d03e82b84afa47d175ee86c4236 100644 (file)
@@ -2020,7 +2020,7 @@ class Diaspora
                        }
 
                        Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $author_contact['cid']]);
-                       if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['uri-id'], $author_contact['cid'], $datarray['uid'])) {
+                       if (Worker::add(Worker::PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['uri-id'], $author_contact['cid'], $datarray['uid'])) {
                                Post\DeliveryData::incrementQueueCount($comment['uri-id'], 1);
                        }
                }
index 7ff86c1db7d247b1e893078b90f77792095d9670..f1521ac2dd344c7fea07e70a34db40bdf5649fde 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Content\Text\HTML;
 use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -630,7 +631,7 @@ class Feed
                                unset($item['parent-uri']);
 
                                // Set the delivery priority for "remote self" to "medium"
-                               $notify = PRIORITY_MEDIUM;
+                               $notify = Worker::PRIORITY_MEDIUM;
                        }
 
                        $condition = ['uid' => $item['uid'], 'uri' => $item['uri']];
index 4d1c3b6374638f0e316a245325931cceadecbe9d..f612cd2ee96efe88c3e5cb89c2df38a86f6d3154 100644 (file)
@@ -34,7 +34,7 @@ class CheckDeletedContacts
        {
                $contacts = DBA::select('contact', ['id'], ['deleted' => true]);
                while ($contact = DBA::fetch($contacts)) {
-                       Worker::add(PRIORITY_MEDIUM, 'Contact\Remove', $contact['id']);
+                       Worker::add(Worker::PRIORITY_MEDIUM, 'Contact\Remove', $contact['id']);
                }
                DBA::close($contacts);
        }
index 12ea6e60a36c8fffd9217301f74b0124b5d9f2db..21d2f8a20560fcb95804a5e7a45cdfdba477257a 100644 (file)
@@ -62,25 +62,25 @@ class Cron
                }
 
                // Fork the cron jobs in separate parts to avoid problems when one of them is crashing
-               Hook::fork(PRIORITY_MEDIUM, 'cron');
+               Hook::fork(Worker::PRIORITY_MEDIUM, 'cron');
 
                // Poll contacts
-               Worker::add(PRIORITY_MEDIUM, 'PollContacts');
+               Worker::add(Worker::PRIORITY_MEDIUM, 'PollContacts');
 
                // Update contact information
-               Worker::add(PRIORITY_LOW, 'UpdateContacts');
+               Worker::add(Worker::PRIORITY_LOW, 'UpdateContacts');
 
                // Update server information
-               Worker::add(PRIORITY_LOW, 'UpdateGServers');
+               Worker::add(Worker::PRIORITY_LOW, 'UpdateGServers');
 
                // run the process to update server directories in the background
-               Worker::add(PRIORITY_LOW, 'UpdateServerDirectories');
+               Worker::add(Worker::PRIORITY_LOW, 'UpdateServerDirectories');
 
                // Expire and remove user entries
-               Worker::add(PRIORITY_MEDIUM, 'ExpireAndRemoveUsers');
+               Worker::add(Worker::PRIORITY_MEDIUM, 'ExpireAndRemoveUsers');
 
                // Call possible post update functions
-               Worker::add(PRIORITY_LOW, 'PostUpdate');
+               Worker::add(Worker::PRIORITY_LOW, 'PostUpdate');
 
                // Hourly cron calls
                if (DI::config()->get('system', 'last_cron_hourly', 0) + 3600 < time()) {
@@ -97,11 +97,11 @@ class Cron
 
                        // Search for new contacts in the directory
                        if (DI::config()->get('system', 'synchronize_directory')) {
-                               Worker::add(PRIORITY_LOW, 'PullDirectory');
+                               Worker::add(Worker::PRIORITY_LOW, 'PullDirectory');
                        }
 
                        // Clear cache entries
-                       Worker::add(PRIORITY_LOW, 'ClearCache');
+                       Worker::add(Worker::PRIORITY_LOW, 'ClearCache');
 
                        DI::config()->set('system', 'last_cron_hourly', time());
                }
@@ -109,27 +109,27 @@ class Cron
                // Daily maintenance cron calls
                if (Worker::isInMaintenanceWindow(true)) {
 
-                       Worker::add(PRIORITY_LOW, 'UpdateContactBirthdays');
+                       Worker::add(Worker::PRIORITY_LOW, 'UpdateContactBirthdays');
 
-                       Worker::add(PRIORITY_LOW, 'UpdatePhotoAlbums');
+                       Worker::add(Worker::PRIORITY_LOW, 'UpdatePhotoAlbums');
 
-                       Worker::add(PRIORITY_LOW, 'ExpirePosts');
+                       Worker::add(Worker::PRIORITY_LOW, 'ExpirePosts');
 
-                       Worker::add(PRIORITY_LOW, 'ExpireActivities');
+                       Worker::add(Worker::PRIORITY_LOW, 'ExpireActivities');
 
-                       Worker::add(PRIORITY_LOW, 'RemoveUnusedTags');
+                       Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedTags');
 
-                       Worker::add(PRIORITY_LOW, 'RemoveUnusedContacts');
+                       Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedContacts');
 
-                       Worker::add(PRIORITY_LOW, 'RemoveUnusedAvatars');
+                       Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedAvatars');
 
                        // check upstream version?
-                       Worker::add(PRIORITY_LOW, 'CheckVersion');
+                       Worker::add(Worker::PRIORITY_LOW, 'CheckVersion');
 
-                       Worker::add(PRIORITY_LOW, 'CheckDeletedContacts');
+                       Worker::add(Worker::PRIORITY_LOW, 'CheckDeletedContacts');
 
                        if (DI::config()->get('system', 'optimize_tables')) {
-                               Worker::add(PRIORITY_LOW, 'OptimizeTables');
+                               Worker::add(Worker::PRIORITY_LOW, 'OptimizeTables');
                        }
 
                        // Resubscribe to relay servers
index bb8041a2251e0e919b231ff623d6c9d2afa948cd..f0ee2ab5d10c97df54492aef2cdc96af6944fe06 100644 (file)
@@ -64,7 +64,7 @@ class Directory
        private static function updateAll() {
                $users = DBA::select('owner-view', ['url'], ['net-publish' => true, 'account_expired' => false, 'verified' => true]);
                while ($user = DBA::fetch($users)) {
-                       Worker::add(PRIORITY_LOW, 'Directory', $user['url']);
+                       Worker::add(Worker::PRIORITY_LOW, 'Directory', $user['url']);
                }
                DBA::close($users);
        }
index bbdfaa42c7e94d19d80d0eaaea6d7641f8df0c62..ffb40e697ec28556a81330ce76af06ed606838e0 100644 (file)
@@ -53,10 +53,10 @@ class ExpirePosts
                }
 
                // Set the expiry for origin posta
-               Worker::add(PRIORITY_LOW, 'Expire');
+               Worker::add(Worker::PRIORITY_LOW, 'Expire');
 
                // update nodeinfo data after everything is cleaned up
-               Worker::add(PRIORITY_LOW, 'NodeInfo');
+               Worker::add(Worker::PRIORITY_LOW, 'NodeInfo');
        }
 
        /**
index 4b24caf5ba3421a6a48daf6f93f713b073349a59..30f42e40cd7ba8884494b3b38fc36b30fe6a47d1 100644 (file)
@@ -37,7 +37,7 @@ class MoveStorage
                $moved   = DI::storageManager()->move($current);
 
                if ($moved) {
-                       Worker::add(PRIORITY_LOW, 'MoveStorage');
+                       Worker::add(Worker::PRIORITY_LOW, 'MoveStorage');
                }
        }
 }
index 7d3d3d6b7cc7033a1a8d06d18d78361d7e893c42..45dc4de30949257eef48786bee69d6486e735b43 100644 (file)
@@ -86,7 +86,7 @@ class Notifier
                        foreach ($inboxes as $inbox => $receivers) {
                                $ap_contacts = array_merge($ap_contacts, $receivers);
                                Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]);
-                               Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
+                               Worker::add(['priority' => Worker::PRIORITY_HIGH, 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
                                        'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid);
                        }
                } elseif ($cmd == Delivery::SUGGESTION) {
@@ -568,7 +568,7 @@ class Notifier
                        // Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
                        // The conversion in Markdown reduces the formatting, so these posts should arrive after the Friendica posts.
                        // This is only important for high and medium priority tasks and not for Low priority jobs like deletions.
-                       if (($contact['network'] == Protocol::DIASPORA) && in_array($a->getQueueValue('priority'), [PRIORITY_HIGH, PRIORITY_MEDIUM])) {
+                       if (($contact['network'] == Protocol::DIASPORA) && in_array($a->getQueueValue('priority'), [Worker::PRIORITY_HIGH, Worker::PRIORITY_MEDIUM])) {
                                $deliver_options = ['priority' => $a->getQueueValue('priority'), 'dont_fork' => true];
                        } else {
                                $deliver_options = ['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true];
@@ -698,7 +698,7 @@ class Notifier
                $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($self_user_id);
                foreach ($inboxes as $inbox => $receivers) {
                        Logger::info('Account removal via ActivityPub', ['uid' => $self_user_id, 'inbox' => $inbox]);
-                       Worker::add(['priority' => PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
+                       Worker::add(['priority' => Worker::PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
                                'APDelivery', Delivery::REMOVAL, 0, $inbox, $self_user_id, $receivers);
                        Worker::coolDown();
                }
@@ -817,7 +817,7 @@ class Notifier
                        if (DI::config()->get('system', 'bulk_delivery')) {
                                $delivery_queue_count++;
                                Post\Delivery::add($target_item['uri-id'], $uid, $inbox, $target_item['created'], $cmd, $receivers);
-                               Worker::add(PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
+                               Worker::add(Worker::PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
                        } else {
                                if (Worker::add(['priority' => $priority, 'created' => $created, 'dont_fork' => true],
                                                'APDelivery', $cmd, $target_item['id'], $inbox, $uid, $receivers, $target_item['uri-id'])) {
@@ -834,7 +834,7 @@ class Notifier
                        if (DI::config()->get('system', 'bulk_delivery')) {
                                $delivery_queue_count++;
                                Post\Delivery::add($target_item['uri-id'], $uid, $inbox, $target_item['created'], $cmd, []);
-                               Worker::add(PRIORITY_MEDIUM, 'APDelivery', '', 0, $inbox, 0);
+                               Worker::add(Worker::PRIORITY_MEDIUM, 'APDelivery', '', 0, $inbox, 0);
                        } else {
                                if (Worker::add(['priority' => $priority, 'dont_fork' => true], 'APDelivery', $cmd, $target_item['id'], $inbox, $uid, [], $target_item['uri-id'])) {
                                        $delivery_queue_count++;
index b4312ef0c3022cab852d8b97f57ab3facde3a411..454b5a9aea46c80335825b4bf39543eb8d7fe808 100644 (file)
@@ -71,11 +71,11 @@ class PollContacts
                        }
 
                        if ((($contact['network'] == Protocol::FEED) && ($contact['priority'] <= 3)) || ($contact['network'] == Protocol::MAIL)) {
-                               $priority = PRIORITY_MEDIUM;
+                               $priority = Worker::PRIORITY_MEDIUM;
                        } elseif ($contact['archive']) {
-                               $priority = PRIORITY_NEGLIGIBLE;
+                               $priority = Worker::PRIORITY_NEGLIGIBLE;
                        } else {
-                               $priority = PRIORITY_LOW;
+                               $priority = Worker::PRIORITY_LOW;
                        }
 
                        Logger::notice("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
index 6a2d54422eb7fd99bbdfe1ff174522e0a56159c4..72ead5264292c7c543df91aee66ef69af83e9df8 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Worker;
 
+use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
@@ -48,7 +49,7 @@ class RemoveUser {
                do {
                        $items = Post::select(['id'], $condition, ['limit' => 100]);
                        while ($item = Post::fetch($items)) {
-                               Item::markForDeletionById($item['id'], PRIORITY_NEGLIGIBLE);
+                               Item::markForDeletionById($item['id'], Worker::PRIORITY_NEGLIGIBLE);
                        }
                        DBA::close($items);
                } while (Post::exists($condition));
index 7e352a27caf9f683bee524c8205cf8cf3993a5f4..ed4a9932f134aa3ed688e4292a4ebff809da73ec 100644 (file)
@@ -59,7 +59,7 @@ class UpdateContacts
                $contacts = DBA::select('contact', ['id'], $condition, ['order' => ['next-update'], 'limit' => $limit]);
                $count = 0;
                while ($contact = DBA::fetch($contacts)) {
-                       if (Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "UpdateContact", $contact['id'])) {
+                       if (Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], "UpdateContact", $contact['id'])) {
                                ++$count;
                        }
                        Worker::coolDown();
index 108482eaecef4035336e8b1c7797c3f8ddacde29..25a2db16e0f8ac22b5bc95f98f698a4558c7c6b9 100644 (file)
@@ -63,12 +63,12 @@ class UpdateGServers
                        // There are duplicated "url" but not "nurl". So we check both addresses instead of just overwriting them,
                        // since that would mean loosing data.
                        if (!empty($gserver['url'])) {
-                               if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url'])) {
+                               if (Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $gserver['url'])) {
                                        $count++;
                                }
                        }
                        if (!empty($gserver['nurl']) && ($gserver['nurl'] != Strings::normaliseLink($gserver['url']))) {
-                               if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['nurl'])) {
+                               if (Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $gserver['nurl'])) {
                                        $count++;
                                }
                        }
index f20b333dd8a4667969c1179bd3093ba88a2e6d62..647fb73b13ffc325cf689a7171e45a7230daee59 100644 (file)
@@ -284,7 +284,7 @@ return [
 
                // expire-notify-priority (integer)
                // Priority for the expirary notification 
-               'expire-notify-priority' => PRIORITY_LOW,
+               'expire-notify-priority' => Friendica\Core\Worker::PRIORITY_LOW,
 
                // fetch_by_worker (Boolean)
                // Fetch missing posts via a background process
index fab51993c16359026206253c9262e3bbb8486ea1..9f348efe62b1dc04adef7ac4ab8d130f93e85d44 100644 (file)
@@ -131,7 +131,7 @@ function update_1309()
                        continue;
                }
 
-               $deliver_options = ['priority' => PRIORITY_MEDIUM, 'dont_fork' => true];
+               $deliver_options = ['priority' => Worker::PRIORITY_MEDIUM, 'dont_fork' => true];
                Worker::add($deliver_options, 'Delivery', Delivery::POST, $item['id'], $entry['cid']);
                Logger::info('Added delivery worker', ['item' => $item['id'], 'contact' => $entry['cid']]);
                DBA::delete('queue', ['id' => $entry['id']]);
@@ -152,7 +152,7 @@ function update_1318()
        DBA::update('profile', ['marital' => 'In a relation'], ['marital' => 'Unavailable']);
        DBA::update('profile', ['marital' => 'Single'], ['marital' => 'Available']);
 
-       Worker::add(PRIORITY_LOW, 'ProfileUpdate');
+       Worker::add(Worker::PRIORITY_LOW, 'ProfileUpdate');
        return Update::SUCCESS;
 }