diff --git a/libraries/src/Application/AdministratorApplication.php b/libraries/src/Application/AdministratorApplication.php index b12d3cc970da6..8b3994ffe42f8 100644 --- a/libraries/src/Application/AdministratorApplication.php +++ b/libraries/src/Application/AdministratorApplication.php @@ -231,7 +231,15 @@ public function getTemplate($params = false) $db = Factory::getDbo(); $query = $db->getQuery(true) - ->select($db->quoteName(['s.template', 's.params', 's.inheritable', 's.parent'])) + /* + * It is important to use the asterisk for THIS select query here. + * It is needed due to the core update process. + * Depending on the version before the update new database columns are used before they exist. + * This causes the update to crash with SQL error. + * + * Can be reviewed for Joomla! 5.0 + */ + ->select('s.*') ->from($db->quoteName('#__template_styles', 's')) ->join( 'LEFT', @@ -265,7 +273,18 @@ public function getTemplate($params = false) $template = $db->loadObject(); $template->template = InputFilter::getInstance()->clean($template->template, 'cmd'); - $template->params = new Registry($template->params); + $template->params = new Registry($template->params); + + // We have to check required properties which may not exist during the upgrade process + if (!property_exists($template, 'parent')) + { + $template->parent = ''; + } + + if (!property_exists($template, 'inheritable')) + { + $template->inheritable = 0; + } // Fallback template if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php') diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php index da5d10d5b8a64..800185490a9c2 100644 --- a/libraries/src/HTML/HTMLHelper.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -440,7 +440,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec $template = $app->getTemplate(true); $templaPath = JPATH_THEMES; - if ($template->inheritable || !empty($template->parent)) + if (!empty($template->inheritable) || !empty($template->parent)) { $client = $app->isClient('administrator') === true ? 'administrator' : 'site'; $templaPath = JPATH_ROOT . "/media/templates/$client"; diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index 579ad4257e5b7..a01136739ce7f 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -335,7 +335,12 @@ public static function getLayoutPath($module, $layout = 'default') // Build the template and base path for the layout $tPath = JPATH_THEMES . '/' . $template . '/html/' . $module . '/' . $layout . '.php'; - $iPath = JPATH_THEMES . '/' . $templateObj->parent . '/html/' . $module . '/' . $layout . '.php'; + + if (!empty($templateObj->parent)) + { + $iPath = JPATH_THEMES . '/' . $templateObj->parent . '/html/' . $module . '/' . $layout . '.php'; + } + $bPath = JPATH_BASE . '/modules/' . $module . '/tmpl/' . $defaultLayout . '.php'; $dPath = JPATH_BASE . '/modules/' . $module . '/tmpl/default.php';