diff --git a/lib/Factory/MediaFactory.php b/lib/Factory/MediaFactory.php index 758696fecf..c2c77f5230 100644 --- a/lib/Factory/MediaFactory.php +++ b/lib/Factory/MediaFactory.php @@ -791,9 +791,14 @@ public function query($sortOrder = null, $filterBy = []) ON widget.widgetId = lkwidgetmedia.widgetId WHERE region.layoutId = :layoutId '; - // include Media only for non dynamic Playlists #2392 + // include Media only for non-dynamic Playlists #2392 if ($sanitizedFilter->getInt('excludeDynamicPlaylistMedia') === 1) { - $body .= ' AND lkplaylistplaylist.childId IN (SELECT playlistId FROM playlist WHERE playlist.playlistId = lkplaylistplaylist.childId AND playlist.isDynamic = 0) '; + $body .= ' AND lkplaylistplaylist.childId IN ( + SELECT playlistId + FROM playlist + WHERE playlist.playlistId = lkplaylistplaylist.childId + AND playlist.isDynamic = 0 + ) '; } if ($sanitizedFilter->getInt('widgetId') !== null) { @@ -801,14 +806,18 @@ public function query($sortOrder = null, $filterBy = []) $params['widgetId'] = $sanitizedFilter->getInt('widgetId'); } + if ($sanitizedFilter->getInt('includeLayoutBackgroundImage') === 1) { + $body .= ' UNION ALL + SELECT `layout`.backgroundImageId AS mediaId + FROM `layout` + WHERE `layout`.layoutId = :layoutId + '; + } + $body .= ' ) AND media.type <> \'module\' '; - if ($sanitizedFilter->getInt('includeLayoutBackgroundImage') === 1) { - $body .= ' OR media.mediaId IN ( SELECT `layout`.backgroundImageId FROM `layout` WHERE `layout`.layoutId = :layoutId ) '; - } - $params['layoutId'] = $sanitizedFilter->getInt('layoutId'); } diff --git a/lib/Factory/ModuleTemplateFactory.php b/lib/Factory/ModuleTemplateFactory.php index 6a6e967300..4c2f39fe62 100644 --- a/lib/Factory/ModuleTemplateFactory.php +++ b/lib/Factory/ModuleTemplateFactory.php @@ -340,7 +340,7 @@ public function loadUserTemplates($sortOrder = [], $filterBy = []): array $template->templateId = $row['templateId']; $template->dataType = $row['dataType']; $template->isEnabled = $row['enabled'] == 1; - $template->ownerId = intval($row['ownerId']); + $template->ownerId = intval($row['ownerId'] ?? 0); $template->groupsWithPermissions = $row['groupsWithPermissions']; $templates[] = $template; }