From 43b61d26e86e5fafd22e7b77c9139b07313ad44f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 20 Jul 2022 15:49:08 +0200 Subject: [PATCH] don't hard error when trying to load profiles with no profiler registered Signed-off-by: Robin Appelman --- lib/private/Profiler/Profiler.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/private/Profiler/Profiler.php b/lib/private/Profiler/Profiler.php index 9fd5e76d59212..40050b7bf4388 100644 --- a/lib/private/Profiler/Profiler.php +++ b/lib/private/Profiler/Profiler.php @@ -61,11 +61,19 @@ public function loadProfileFromResponse(Response $response): ?IProfile { } 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 @@ public function collect(Request $request, Response $response): IProfile { */ 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 {