]> source.dussan.org Git - nextcloud-server.git/commitdiff
don't hard error when trying to load profiles with no profiler registered 33292/head
authorRobin Appelman <robin@icewind.nl>
Wed, 20 Jul 2022 13:49:08 +0000 (15:49 +0200)
committerRobin Appelman <robin@icewind.nl>
Tue, 4 Apr 2023 15:24:29 +0000 (17:24 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Profiler/Profiler.php

index 9fd5e76d592124e948a10fb7d4655a09dacd2f3b..40050b7bf43885aa8bbf7d7b9ff385426ee8cf85 100644 (file)
@@ -61,11 +61,19 @@ class Profiler implements IProfiler {
        }
 
        public function loadProfile(string $token): ?IProfile {
-               return $this->storage->read($token);
+               if ($this->storage) {
+                       return $this->storage->read($token);
+               } else {
+                       return null;
+               }
        }
 
        public function saveProfile(IProfile $profile): bool {
-               return $this->storage->write($profile);
+               if ($this->storage) {
+                       return $this->storage->write($profile);
+               } else {
+                       return false;
+               }
        }
 
        public function collect(Request $request, Response $response): IProfile {
@@ -88,7 +96,11 @@ class Profiler implements IProfiler {
         */
        public function find(?string $url, ?int $limit, ?string $method, ?int $start, ?int $end,
                                                 string $statusCode = null): array {
-               return $this->storage->find($url, $limit, $method, $start, $end, $statusCode);
+               if ($this->storage) {
+                       return $this->storage->find($url, $limit, $method, $start, $end, $statusCode);
+               } else {
+                       return [];
+               }
        }
 
        public function dataProviders(): array {