diff --git a/src/Core/Logger/Factory/LegacyLoggerFactory.php b/src/Core/Logger/Factory/LegacyLoggerFactory.php index 485f3b09dc..5c91d11771 100644 --- a/src/Core/Logger/Factory/LegacyLoggerFactory.php +++ b/src/Core/Logger/Factory/LegacyLoggerFactory.php @@ -15,7 +15,17 @@ use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; /** - * Manager for the core logging instances + * Bridge for the legacy Logger factory. + * + * This class can be removed after the following classes are replaced or + * refactored implementing the `\Friendica\Core\Logger\Factory\LoggerFactory`: + * + * - Friendica\Core\Logger\Factory\StreamLogger + * - Friendica\Core\Logger\Factory\SyslogLogger + * - monolog addon: Friendica\Addon\monolog\src\Factory\Monolog + * + * @see \Friendica\Core\Logger\Factory\StreamLogger + * @see \Friendica\Core\Logger\Factory\SyslogLogger */ final class LegacyLoggerFactory implements LoggerFactory { diff --git a/src/Module/Photo.php b/src/Module/Photo.php index d2b42811ce..8843e82b0a 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -26,6 +26,7 @@ use Friendica\Network\HTTPException; use Friendica\Network\HTTPException\NotModifiedException; use Friendica\Object\Image; use Friendica\Security\OpenWebAuth; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; use Friendica\Util\ParseUrl; use Friendica\Util\Proxy; @@ -296,7 +297,7 @@ class Photo extends BaseApi return MPhoto::createPhotoForExternalResource($link['url'], (int)DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '', $link['blurhash'] ?? '', $link['width'] ?? 0, $link['height'] ?? 0); case 'contact': - $fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated']; + $fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated', 'next-update']; $contact = Contact::getById($id, $fields); if (empty($contact)) { return false; @@ -354,7 +355,7 @@ class Photo extends BaseApi } 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); diff --git a/src/Worker/UpdateContact.php b/src/Worker/UpdateContact.php index 059a8134c5..88f157ad51 100644 --- a/src/Worker/UpdateContact.php +++ b/src/Worker/UpdateContact.php @@ -51,6 +51,7 @@ class UpdateContact return 0; } + DI::logger()->debug('Update contact', ['id' => $contact_id]); return Worker::add($run_parameters, 'UpdateContact', $contact_id); } } diff --git a/tests/Unit/Core/Logger/LoggerManagerTest.php b/tests/Unit/Core/Logger/LoggerManagerTest.php index 14db1c2676..02f9c0b2e2 100644 --- a/tests/Unit/Core/Logger/LoggerManagerTest.php +++ b/tests/Unit/Core/Logger/LoggerManagerTest.php @@ -21,12 +21,25 @@ use Psr\Log\NullLogger; class LoggerManagerTest extends TestCase { - public function testGetLoggerReturnsPsrLogger(): void + /** + * Clean the private static properties + * + * @see LoggerManager::$logger + * @see LoggerManager::$logChannel + */ + protected function tearDown(): void { $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue(null, null); + $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logChannel'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue(null, LogChannel::DEFAULT); + } + + public function testGetLoggerReturnsPsrLogger(): void + { $factory = new LoggerManager( $this->createStub(IManageConfigValues::class), $this->createStub(LoggerFactory::class) @@ -37,10 +50,6 @@ class LoggerManagerTest extends TestCase public function testGetLoggerReturnsSameObject(): void { - $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue(null, null); - $factory = new LoggerManager( $this->createStub(IManageConfigValues::class), $this->createStub(LoggerFactory::class) @@ -56,10 +65,6 @@ class LoggerManagerTest extends TestCase ['system', 'debugging', null, false], ]); - $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue(null, null); - $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) @@ -76,10 +81,6 @@ class LoggerManagerTest extends TestCase ['system', 'profiling', null, true], ]); - $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue(null, null); - $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) @@ -96,10 +97,6 @@ class LoggerManagerTest extends TestCase ['system', 'profiling', null, true], ]); - $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue(null, null); - $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class) @@ -120,10 +117,6 @@ class LoggerManagerTest extends TestCase ['system', 'profiling', null, true], ]); - $reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue(null, null); - $factory = new LoggerManager( $config, $this->createStub(LoggerFactory::class)