]> git.mxchange.org Git - friendica.git/commitdiff
Use non static logger call
authorMichael <heluecht@pirati.ca>
Mon, 27 Feb 2023 07:02:06 +0000 (07:02 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 27 Feb 2023 07:02:06 +0000 (07:02 +0000)
src/Core/Storage/Repository/StorageManager.php
src/Core/Storage/Type/ExternalResource.php

index fbe910d01d413894df4e31bd7b31abaaed3e53f1..252454665de5dfb58d6b0da7c7826a1d1ca8a7c0 100644 (file)
@@ -168,7 +168,7 @@ class StorageManager
 
                                        return $data['storage_config'];
                                } catch (InternalServerErrorException $exception) {
-                                       throw new StorageException(sprintf('Failed calling hook::storage_config for backend %s', $name), $exception);
+                                       throw new StorageException(sprintf('Failed calling hook::storage_config for backend %s', $name), $exception->__toString());
                                }
                }
        }
@@ -208,7 +208,7 @@ class StorageManager
                                        $this->backendInstances[$name] = new Type\SystemResource();
                                        break;
                                case Type\ExternalResource::getName():
-                                       $this->backendInstances[$name] = new Type\ExternalResource();
+                                       $this->backendInstances[$name] = new Type\ExternalResource($this->logger);
                                        break;
                                default:
                                        $data = [
@@ -223,7 +223,7 @@ class StorageManager
 
                                                $this->backendInstances[$data['name'] ?? $name] = $data['storage'];
                                        } catch (InternalServerErrorException $exception) {
-                                               throw new StorageException(sprintf('Failed calling hook::storage_instance for backend %s', $name), $exception);
+                                               throw new StorageException(sprintf('Failed calling hook::storage_instance for backend %s', $name), $exception->__toString());
                                        }
                                        break;
                        }
index 54d47e5bf447b351b36a45db24d13e351d9d60f0..181312a5bf62a0dc61c61e655249b15a7a05a749 100644 (file)
 namespace Friendica\Core\Storage\Type;
 
 use Exception;
-use Friendica\Core\Logger;
 use Friendica\Core\Storage\Exception\ReferenceStorageException;
 use Friendica\Core\Storage\Capability\ICanReadFromStorage;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Util\HTTPSignature;
+use Psr\Log\LoggerInterface;
 
 /**
  * External resource storage class
@@ -39,6 +39,14 @@ class ExternalResource implements ICanReadFromStorage
 {
        const NAME = 'ExternalResource';
 
+       /** @var LoggerInterface */
+       protected $logger;
+
+       public function __construct(LoggerInterface $logger)
+       {
+               $this->logger = $logger;
+       }
+
        /**
         * @inheritDoc
         */
@@ -57,11 +65,11 @@ class ExternalResource implements ICanReadFromStorage
                try {
                        $fetchResult = HTTPSignature::fetchRaw($data->url, $data->uid, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
                } catch (Exception $exception) {
-                       Logger::notice('URL is invalid', ['url' => $data->url, 'error' => $exception]);
+                       $this->logger->notice('URL is invalid', ['url' => $data->url, 'error' => $exception]);
                        throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
                }
                if (!empty($fetchResult) && $fetchResult->isSuccess()) {
-                       Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
+                       $this->logger->debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
                        return $fetchResult->getBody();
                } else {
                        if (empty($fetchResult)) {