]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/UpdateGServers.php
Only attach images
[friendica.git] / src / Worker / UpdateGServers.php
index 486dbc93c225ecfe96d9c96571c7549ba39a85c6..108482eaecef4035336e8b1c7797c3f8ddacde29 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -25,6 +25,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
 
 class UpdateGServers
@@ -47,7 +48,7 @@ class UpdateGServers
                }
 
                $total = DBA::count('gserver');
-               $condition = ["`next_contact` < UTC_TIMESTAMP() AND (`nurl` != ? OR `url` != ?)", '', ''];
+               $condition = ["`next_contact` < ? AND (`nurl` != ? OR `url` != ?)",  DateTimeFormat::utcNow(), '', ''];
                $outdated = DBA::count('gserver', $condition);
                Logger::info('Server status', ['total' => $total, 'outdated' => $outdated, 'updating' => $limit]);
 
@@ -62,12 +63,16 @@ 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'])) {
-                               Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url']);
+                               if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url'])) {
+                                       $count++;
+                               }
                        }
                        if (!empty($gserver['nurl']) && ($gserver['nurl'] != Strings::normaliseLink($gserver['url']))) {
-                               Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['nurl']);
+                               if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['nurl'])) {
+                                       $count++;
+                               }
                        }
-                       $count++;
+                       Worker::coolDown();
                }
                DBA::close($gservers);
                Logger::info('Updated servers', ['count' => $count]);