diff --git a/administrator/components/com_admin/sql/updates/mysql/4.2.3-2022-09-07.sql b/administrator/components/com_admin/sql/updates/mysql/4.2.3-2022-09-07.sql new file mode 100644 index 0000000000000..dd92e8986d4e3 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.2.3-2022-09-07.sql @@ -0,0 +1,2 @@ +-- Remove the record of any template overrides where the template has already been uninstalled +DELETE FROM `#__template_overrides` WHERE `template` NOT IN (SELECT `name` FROM `#__extensions` WHERE `type`='template'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.2.3-2022-09-07.sql b/administrator/components/com_admin/sql/updates/postgresql/4.2.3-2022-09-07.sql new file mode 100644 index 0000000000000..355f68e1b4685 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.2.3-2022-09-07.sql @@ -0,0 +1,2 @@ +-- Remove the record of any template overrides where the template has already been uninstalled +DELETE FROM "#__template_overrides" WHERE "template" NOT IN (SELECT "name" FROM "#__extensions" WHERE "type"='template'); diff --git a/libraries/src/Installer/Adapter/TemplateAdapter.php b/libraries/src/Installer/Adapter/TemplateAdapter.php index 2d00dd2ec1473..4373980e6e50e 100644 --- a/libraries/src/Installer/Adapter/TemplateAdapter.php +++ b/libraries/src/Installer/Adapter/TemplateAdapter.php @@ -227,6 +227,14 @@ protected function finaliseUninstall(): bool $db->setQuery($query); $db->execute(); + // Remove any overrides + $query = $db->getQuery(true) + ->delete($db->quoteName('#__template_overrides')) + ->where($db->quoteName('template') . ' = :template') + ->bind(':template', $element); + $db->setQuery($query); + $db->execute(); + // Clobber any possible pending updates $update = Table::getInstance('update'); $uid = $update->find(