From a4e2a7bb7bca8a374dd5d644c0c191dedfca9201 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sun, 27 Oct 2024 19:37:25 +0800 Subject: [PATCH] fix(appsmanagement): Fix exception on generating preview url for screenshots Some installed apps meant for older server versions might unexpectedly offer up screenshot values in a non-string format (e.g. health). Avoid an exception by checking first if the first app screenshot is indeed a string and otherwise we take the value of the parameter Signed-off-by: Claudio Cambra --- apps/settings/lib/Controller/AppSettingsController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index e4a36c986fe..554420862a6 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -254,9 +254,15 @@ class AppSettingsController extends Controller { $apps = $appClass->listAllApps(); foreach ($apps as $app) { $app['installed'] = true; - // locally installed apps have a flatted screenshot property + if (isset($app['screenshot'][0])) { - $app['screenshot'] = $this->createProxyPreviewUrl($app['screenshot'][0]); + $appScreenshot = $app['screenshot'][0] ?? null; + if (is_array($appScreenshot)) { + // Screenshot with thumbnail + $appScreenshot = $appScreenshot['@value']; + } + + $app['screenshot'] = $this->createProxyPreviewUrl($appScreenshot); } $this->allApps[$app['id']] = $app; }