diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 9b7df3f8b6684..f2eabeb3472e2 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -58,6 +58,9 @@ public function preflight($action, $installer) { $this->fromVersion = $manifestValues['version']; + // Ensure templates are moved to the correct mode + $this->fixTemplateMode(); + return true; } } @@ -8537,4 +8540,40 @@ protected function moveRemainingTemplateFiles() } } } + + /** + * Ensure the core templates are correctly moved to the new mode. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + protected function fixTemplateMode(): void + { + $db = Factory::getContainer()->get('DatabaseDriver'); + + array_map( + function ($template) use ($db) + { + $clientId = $template === 'atum' ? 1 : 0; + $query = $db->getQuery(true) + ->update($db->quoteName('#__template_styles')) + ->set($db->quoteName('inheritable') . ' = 1') + ->where($db->quoteName('template') . ' = ' . $db->quote($template)) + ->where($db->quoteName('client_id') . ' = ' . $clientId); + + try + { + $db->setQuery($query)->execute(); + } + catch (Exception $e) + { + echo Text::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '
'; + + return; + } + }, + ['atum', 'cassiopeia'] + ); + } } diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-03-05.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-03-05.sql index dbae8b67ed550..c025f92818264 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-03-05.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-03-05.sql @@ -19,9 +19,11 @@ INSERT INTO `#__extensions` (`name`, `type`, `element`, `folder`, `client_id`, ` ('atum', 'template', 'atum', '', 1, 1, 1, 0, '{}', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0), ('cassiopeia', 'template', 'cassiopeia', '', 0, 1, 1, 0, '{}', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0); -INSERT INTO `#__template_styles` (`template`, `client_id`, `home`, `title`, `params`) VALUES -('atum', 1, (CASE WHEN (SELECT b.`count` FROM (SELECT count(a.`id`) AS `count` FROM `#__template_styles` a WHERE a.`home` = '1' AND a.`client_id` = 1 AND a.`template` IN ('isis', 'hathor')) AS b) = 0 THEN '0' ELSE '1' END), 'atum - Default', '{}'), -('cassiopeia', 0, (CASE WHEN (SELECT d.`count` FROM (SELECT count(c.`id`) AS `count` FROM `#__template_styles` c WHERE c.`home` = '1' AND c.`client_id` = 0 AND c.`template` IN ('protostar', 'beez3')) AS d) = 0 THEN '0' ELSE '1' END), 'cassiopeia - Default', '{}'); +-- The following statement had to be modified for 4.1 by adding the `inheritable` and `parent` columns. +-- See https://github.com/joomla/joomla-cms/pull/36585 . +INSERT INTO `#__template_styles` (`template`, `client_id`, `home`, `title`, `inheritable`, `parent`, `params`) VALUES +('atum', 1, (CASE WHEN (SELECT b.`count` FROM (SELECT count(a.`id`) AS `count` FROM `#__template_styles` a WHERE a.`home` = '1' AND a.`client_id` = 1 AND a.`template` IN ('isis', 'hathor')) AS b) = 0 THEN '0' ELSE '1' END), 'atum - Default', 1, '', '{}'), +('cassiopeia', 0, (CASE WHEN (SELECT d.`count` FROM (SELECT count(c.`id`) AS `count` FROM `#__template_styles` c WHERE c.`home` = '1' AND c.`client_id` = 0 AND c.`template` IN ('protostar', 'beez3')) AS d) = 0 THEN '0' ELSE '1' END), 'cassiopeia - Default', 1, '', '{}'); -- -- Move mod_version to the right position for the atum template diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-03-05.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-03-05.sql index d6620523b6612..ae03fbfcb7f35 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-03-05.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-03-05.sql @@ -19,9 +19,11 @@ INSERT INTO "#__extensions" ("name", "type", "element", "folder", "client_id", " ('atum', 'template', 'atum', '', 1, 1, 1, 0, '{}', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0), ('cassiopeia', 'template', 'cassiopeia', '', 0, 1, 1, 0, '{}', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0); -INSERT INTO "#__template_styles" ("template", "client_id", "home", "title", "params") VALUES -('atum', 1, (CASE WHEN (SELECT b."count" FROM (SELECT count(a."id") AS "count" FROM "#__template_styles" a WHERE a."home" = '1' AND a."client_id" = 1 AND a."template" IN ('isis', 'hathor')) AS b) = 0 THEN '0' ELSE '1' END), 'atum - Default', '{}'), -('cassiopeia', 0, (CASE WHEN (SELECT d."count" FROM (SELECT count(c."id") AS "count" FROM "#__template_styles" c WHERE c."home" = '1' AND c."client_id" = 0 AND c."template" IN ('protostar', 'beez3')) AS d) = 0 THEN '0' ELSE '1' END), 'cassiopeia - Default', '{}'); +-- The following statement had to be modified for 4.1 by adding the "inheritable" and "parent" columns. +-- See https://github.com/joomla/joomla-cms/pull/36585 . +INSERT INTO "#__template_styles" ("template", "client_id", "home", "title", "inheritable", "parent", "params") VALUES +('atum', 1, (CASE WHEN (SELECT b."count" FROM (SELECT count(a."id") AS "count" FROM "#__template_styles" a WHERE a."home" = '1' AND a."client_id" = 1 AND a."template" IN ('isis', 'hathor')) AS b) = 0 THEN '0' ELSE '1' END), 'atum - Default', 1, '', '{}'), +('cassiopeia', 0, (CASE WHEN (SELECT d."count" FROM (SELECT count(c."id") AS "count" FROM "#__template_styles" c WHERE c."home" = '1' AND c."client_id" = 0 AND c."template" IN ('protostar', 'beez3')) AS d) = 0 THEN '0' ELSE '1' END), 'cassiopeia - Default', 1, '', '{}'); -- -- Move mod_version to the right position for the atum template