]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'develop' into refactor-logger-class-with-logger-object
authorArt4 <art4@wlabs.de>
Tue, 14 Jan 2025 09:16:06 +0000 (09:16 +0000)
committerArt4 <art4@wlabs.de>
Tue, 14 Jan 2025 09:16:06 +0000 (09:16 +0000)
1  2 
src/Module/Photo.php
src/Worker/UpdateContact.php

index e176efbddf1617b33694196b33ba796b672b0498,c3582ee6551ba96e2f07f2fd15062c86e4095203..8843e82b0a187ab014b0c6b84734984b2496eca4
@@@ -107,12 -109,12 +108,12 @@@ class Photo extends BaseAp
                                throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.'));
                        }
  
 -                      $photo = self::getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
 +                      $photo = $this->getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
                } else {
                        $photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
-                       $scale = 0;
+                       $scale   = 0;
                        if (substr($photoid, -2, 1) == '-') {
-                               $scale = intval(substr($photoid, -1, 1));
+                               $scale   = intval(substr($photoid, -1, 1));
                                $photoid = substr($photoid, 0, -2);
                        }
  
                $data = microtime(true) - $stamp;
  
                if (empty($imgdata)) {
 -                      Logger::warning('Invalid photo', ['id' => $photo['id']]);
 +                      $this->logger->warning('Invalid photo', ['id' => $photo['id']]);
                        if (in_array($photo['backend-class'], [ExternalResource::NAME])) {
                                $reference = json_decode($photo['backend-ref'], true);
-                               $error = DI::l10n()->t('Invalid external resource with url %s.', $reference['url']);
+                               $error     = DI::l10n()->t('Invalid external resource with url %s.', $reference['url']);
                        } else {
                                $error = DI::l10n()->t('Invalid photo with id %s.', $photo['id']);
                        }
                $output = microtime(true) - $stamp;
  
                $total = microtime(true) - $totalstamp;
-               $rest = $total - ($fetch + $data + $checksum + $output);
+               $rest  = $total - ($fetch + $data + $checksum + $output);
  
                if (!is_null($scale) && ($scale < 4)) {
 -                      Logger::debug('Performance:', [
 +                      $this->logger->debug('Performance:', [
-                               'scale' => $scale, 'resource' => $photo['resource-id'],
-                               'total' => number_format($total, 3), 'fetch' => number_format($fetch, 3),
-                               'data' => number_format($data, 3), 'checksum' => number_format($checksum, 3),
+                               'scale'  => $scale, 'resource' => $photo['resource-id'],
+                               'total'  => number_format($total, 3), 'fetch' => number_format($fetch, 3),
+                               'data'   => number_format($data, 3), 'checksum' => number_format($checksum, 3),
                                'output' => number_format($output, 3), 'rest' => number_format($rest, 3)
                        ]);
                }
                                        } else {
                                                // Only update federated accounts that hadn't failed before and hadn't been updated recently
                                                $update = in_array($contact['network'], Protocol::FEDERATED) && !$contact['failed']
-                                                       && ((time() - strtotime($contact['updated']) > 86400));
+                                                       && ($contact['next-update'] < DateTimeFormat::utcNow());
                                                if ($update) {
                                                        $curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE, HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
-                                                       $update = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
+                                                       $update     = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
 -                                                      Logger::debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
 +                                                      $this->logger->debug('Got return code for avatar', ['return code' => $curlResult->getReturnCode(), 'cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
                                                }
                                                if ($update) {
                                                        try {
index 059a8134c5568bd377d2fd7477e5e48f5e41e387,ded4679fe6a8d52b48de393060d5c0b2be87ea87..88f157ad51aeb3f3c5b268d51ebd57b90c4ac15f
@@@ -51,6 -51,7 +51,7 @@@ class UpdateContac
                        return 0;
                }
  
 -              Logger::debug('Update contact', ['id' => $contact_id]);
++              DI::logger()->debug('Update contact', ['id' => $contact_id]);
                return Worker::add($run_parameters, 'UpdateContact', $contact_id);
        }
  }