]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker/Cron.php
Loglevels are adjusted
[friendica.git] / src / Core / Worker / Cron.php
index 4bf134f7bd807d4f777ab4b095bee8e5b19df783..9db954298ad3b243e3bfbed71affad1685963986 100644 (file)
@@ -25,9 +25,11 @@ use Friendica\Core\Logger;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Contact;
 use Friendica\Model\Post;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Strings;
 
 /**
  * Contains the class for jobs that are executed in an interval
@@ -99,7 +101,7 @@ class Cron
                                // How long is the process already running?
                                $duration = (time() - strtotime($entry["executed"])) / 60;
                                if ($duration > $max_duration) {
-                                       Logger::notice('Worker process took too much time - killed', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
+                                       Logger::warning('Worker process took too much time - killed', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
                                        posix_kill($entry["pid"], SIGTERM);
 
                                        // We killed the stale process.
@@ -179,4 +181,24 @@ class Cron
                        }
                }
        }
+
+       /**
+        * Add missing "intro" records.
+        *
+        * @return void
+        */
+       private static function addIntros()
+       {
+               $contacts = DBA::p("SELECT `uid`, `id`, `created` FROM `contact` WHERE `rel` = ? AND `pending` AND NOT EXISTS (SELECT `id` FROM `intro` WHERE `contact-id` = `contact`.`id`)", Contact::FOLLOWER);
+               while ($contact = DBA::fetch($contacts)) {
+                       $fields = [
+                               'uid'        => $contact['uid'],
+                               'contact-id' => $contact['id'],
+                               'datetime'   => $contact['created'],
+                               'hash'       => Strings::getRandomHex()
+                       ];
+                       Logger::notice('Adding missing intro', ['fields' => $fields]);
+                       DBA::insert('intro', $fields);
+               }
+       }
 }