// Fork the cron jobs in separate parts to avoid problems when one of them is crashing
Hook::fork($a->queue['priority'], "cron");
- // run the process to discover global contacts in the background
- Worker::add(PRIORITY_LOW, "DiscoverPoCo");
+ // run the process to update server directories in the background
+ Worker::add(PRIORITY_LOW, 'UpdateServerDirectories');
// run the process to update locally stored global contacts in the background
- Worker::add(PRIORITY_LOW, 'DiscoverContacts');
+ Worker::add(PRIORITY_LOW, 'UpdateGContacts');
// Expire and remove user entries
Worker::add(PRIORITY_MEDIUM, "CronJobs", "expire_and_remove_users");
// update nodeinfo data
Worker::add(PRIORITY_LOW, "CronJobs", "nodeinfo");
- Worker::add(PRIORITY_LOW, 'UpdateServers');
+ Worker::add(PRIORITY_LOW, 'UpdateGServers');
Worker::add(PRIORITY_LOW, 'UpdateSuggestions');
+++ /dev/null
-<?php
-/**
- * @file src/Worker/DiscoverContacts.php
- */
-namespace Friendica\Worker;
-
-use Friendica\Core\Config;
-use Friendica\Core\Logger;
-use Friendica\Core\Protocol;
-use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\Contact;
-use Friendica\Model\GServer;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Strings;
-
-class DiscoverContacts
-{
- // Updates gcontact entries
- public static function execute()
- {
- if (!Config::get('system', 'poco_completion')) {
- return;
- }
-
- Logger::info('Discover contacts');
-
- $starttime = time();
-
- $contacts = DBA::p("SELECT `url`, `created`, `updated`, `last_failure`, `last_contact`, `server_url`, `network` FROM `gcontact`
- WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
- `last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
- `network` IN (?, ?, ?, ?, '') ORDER BY rand()",
- Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED);
-
- $checked = 0;
-
- while ($contact = DBA::fetch($contacts)) {
- $urlparts = parse_url($contact['url']);
- if (empty($urlparts['scheme'])) {
- DBA::update('gcontact', ['network' => Protocol::PHANTOM],
- ['nurl' => Strings::normaliseLink($contact['url'])]);
- continue;
- }
-
- if (in_array($urlparts['host'], ['twitter.com', 'identi.ca'])) {
- $networks = ['twitter.com' => Protocol::TWITTER, 'identi.ca' => Protocol::PUMPIO];
-
- DBA::update('gcontact', ['network' => $networks[$urlparts['host']]],
- ['nurl' => Strings::normaliseLink($contact['url'])]);
- continue;
- }
-
- $server_url = Contact::getBasepath($contact['url']);
- $force_update = false;
-
- if (!empty($contact['server_url'])) {
- $force_update = (Strings::normaliseLink($contact['server_url']) != Strings::normaliseLink($server_url));
-
- $server_url = $contact['server_url'];
- }
-
- if ((empty($server_url) && ($contact['network'] == Protocol::FEED)) || $force_update || GServer::check($server_url, $contact['network'])) {
- Logger::info('Check profile', ['profile' => $contact['url']]);
- Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact['url'], 'force');
-
- if (++$checked > 100) {
- return;
- }
- } else {
- DBA::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
- ['nurl' => Strings::normaliseLink($contact['url'])]);
- }
-
- // Quit the loop after 3 minutes
- if (time() > ($starttime + 180)) {
- return;
- }
- }
- }
-}
+++ /dev/null
-<?php
-/**
- * @file src/Worker/DiscoverPoCo.php
- */
-namespace Friendica\Worker;
-
-use Friendica\Core\Config;
-use Friendica\Core\Logger;
-use Friendica\Model\GContact;
-use Friendica\Protocol\PortableContact;
-
-class DiscoverPoCo
-{
- public static function execute()
- {
- if (Config::get('system', 'poco_discovery') == PortableContact::DISABLED) {
- return;
- }
-
- // Query Friendica and Hubzilla servers for their users
- PortableContact::discover();
-
- // Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
- if (!Config::get('system', 'ostatus_disabled')) {
- GContact::discoverGsUsers();
- }
- }
-}
--- /dev/null
+<?php
+/**
+ * @file src/Worker/UpdateGContacts.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\Core\Config;
+use Friendica\Core\Logger;
+use Friendica\Core\Protocol;
+use Friendica\Core\Worker;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact;
+use Friendica\Model\GServer;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Strings;
+
+class UpdateGContacts
+{
+ // Updates gcontact entries
+ public static function execute()
+ {
+ if (!Config::get('system', 'poco_completion')) {
+ return;
+ }
+
+ Logger::info('Discover contacts');
+
+ $starttime = time();
+
+ $contacts = DBA::p("SELECT `url`, `created`, `updated`, `last_failure`, `last_contact`, `server_url`, `network` FROM `gcontact`
+ WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
+ `last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
+ `network` IN (?, ?, ?, ?, '') ORDER BY rand()",
+ Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED);
+
+ $checked = 0;
+
+ while ($contact = DBA::fetch($contacts)) {
+ $urlparts = parse_url($contact['url']);
+ if (empty($urlparts['scheme'])) {
+ DBA::update('gcontact', ['network' => Protocol::PHANTOM],
+ ['nurl' => Strings::normaliseLink($contact['url'])]);
+ continue;
+ }
+
+ if (in_array($urlparts['host'], ['twitter.com', 'identi.ca'])) {
+ $networks = ['twitter.com' => Protocol::TWITTER, 'identi.ca' => Protocol::PUMPIO];
+
+ DBA::update('gcontact', ['network' => $networks[$urlparts['host']]],
+ ['nurl' => Strings::normaliseLink($contact['url'])]);
+ continue;
+ }
+
+ $server_url = Contact::getBasepath($contact['url']);
+ $force_update = false;
+
+ if (!empty($contact['server_url'])) {
+ $force_update = (Strings::normaliseLink($contact['server_url']) != Strings::normaliseLink($server_url));
+
+ $server_url = $contact['server_url'];
+ }
+
+ if ((empty($server_url) && ($contact['network'] == Protocol::FEED)) || $force_update || GServer::check($server_url, $contact['network'])) {
+ Logger::info('Check profile', ['profile' => $contact['url']]);
+ Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact['url'], 'force');
+
+ if (++$checked > 100) {
+ return;
+ }
+ } else {
+ DBA::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
+ ['nurl' => Strings::normaliseLink($contact['url'])]);
+ }
+
+ // Quit the loop after 3 minutes
+ if (time() > ($starttime + 180)) {
+ return;
+ }
+ }
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file src/Worker/UpdateGServers.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\Core\Logger;
+use Friendica\Core\Worker;
+use Friendica\Database\DBA;
+use Friendica\Model\GServer;
+
+class UpdateGServers
+{
+ /**
+ * @brief Updates the first 250 servers
+ *
+ */
+ public static function execute()
+ {
+ $gservers = DBA::p("SELECT `url`, `created`, `last_failure`, `last_contact` FROM `gserver` ORDER BY rand()");
+ if (!DBA::isResult($gservers)) {
+ return;
+ }
+
+ $updated = 0;
+
+ while ($gserver = DBA::fetch($gservers)) {
+ if (!GServer::updateNeeded($gserver['created'], '', $gserver['last_failure'], $gserver['last_contact'])) {
+ continue;
+ }
+ Logger::info('Update server status', ['server' => $gserver['url']]);
+
+ Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url']);
+
+ if (++$updated > 250) {
+ return;
+ }
+ }
+ }
+}
--- /dev/null
+<?php
+/**
+ * @file src/Worker/UpdateServerDirectories.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\Core\Config;
+use Friendica\Core\Logger;
+use Friendica\Model\GContact;
+use Friendica\Protocol\PortableContact;
+
+class UpdateServerDirectories
+{
+ public static function execute()
+ {
+ if (Config::get('system', 'poco_discovery') == PortableContact::DISABLED) {
+ return;
+ }
+
+ // Query Friendica and Hubzilla servers for their users
+ PortableContact::discover();
+
+ // Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
+ if (!Config::get('system', 'ostatus_disabled')) {
+ GContact::discoverGsUsers();
+ }
+ }
+}
+++ /dev/null
-<?php
-/**
- * @file src/Worker/UpdateServers.php
- */
-namespace Friendica\Worker;
-
-use Friendica\Core\Logger;
-use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\GServer;
-
-class UpdateServers
-{
- /**
- * @brief Updates the first 250 servers
- *
- */
- public static function execute()
- {
- $gservers = DBA::p("SELECT `url`, `created`, `last_failure`, `last_contact` FROM `gserver` ORDER BY rand()");
- if (!DBA::isResult($gservers)) {
- return;
- }
-
- $updated = 0;
-
- while ($gserver = DBA::fetch($gservers)) {
- if (!GServer::updateNeeded($gserver['created'], '', $gserver['last_failure'], $gserver['last_contact'])) {
- continue;
- }
- Logger::info('Update server status', ['server' => $gserver['url']]);
-
- Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url']);
-
- if (++$updated > 250) {
- return;
- }
- }
- }
-}