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 <developer@claudiocambra.com>
pull/49044/head
Claudio Cambra 2024-10-27 19:37:25 +07:00 committed by backportbot[bot]
parent 9bb42ef557
commit a4e2a7bb7b
1 changed files with 8 additions and 2 deletions

@ -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;
}