No Code Attached Yet
avatar rbuelund
rbuelund
6 Sep 2022

Steps to reproduce the issue

Update J!3 site with protostar template (containing overrides) still installed to J!4. Change default template to Cassiopeia (With no overrides). Uninstall Protostar template.

Expected result

No overrides to check

Actual result

12 overrides to check, which come from the deleted protostar template. Not possible to reset, as the template is uninstalled..

System information (as much as possible)

J!4.2.2
PHP 7.4

Additional comments

avatar rbuelund rbuelund - open - 6 Sep 2022
avatar rbuelund rbuelund - change - 6 Sep 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 6 Sep 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Sep 2022
avatar brianteeman
brianteeman - comment - 6 Sep 2022

Delete Protostar template.

How did you delete it?

avatar rbuelund
rbuelund - comment - 6 Sep 2022

I uninstalled it from backend
Edit: Have edited the original post.

avatar rbuelund rbuelund - change - 6 Sep 2022
The description was changed
avatar rbuelund rbuelund - edited - 6 Sep 2022
avatar richard67
richard67 - comment - 7 Sep 2022

Change default template to Cassiopeia

This change should not have bee necessary after a successful update. The database updates should have done that for you if Protostar or Beez3 was the default template before the update. Has that been the case?

avatar brianteeman
brianteeman - comment - 7 Sep 2022

I can confirm the problem and there is at ;least one other open issue here about this

When you uninstall a template it does NOT remove the database entry for any overrides for that template in #__template_overrides.

As a result the count on the quickicon does not change.

This site was a j3 site that has now been updated to j4

Before

image
image

After uninstalling the template (called editor)

image
image
image

avatar brianteeman
brianteeman - comment - 7 Sep 2022

It probably needs the following code to be added to the finaliseUninstall function in the TemplateAdapter but that will not fix existing problems

        // 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();
avatar PMWilliams123
PMWilliams123 - comment - 7 Sep 2022

What will fix the existing problem?, Do I need too fiddle with the database? If what do I need to do?

avatar richard67
richard67 - comment - 7 Sep 2022

What will fix the existing problem?, Do I need too fiddle with the database? If what do I need to do?

You could use following SQL statements in PhpMyAdmin to clean it up (replace the #__ by your actual database prefix):

DELETE FROM `#__template_overrides` WHERE `template` NOT IN (SELECT `name` FROM `#__extensions` WHERE `type`='template');
avatar brianteeman
brianteeman - comment - 7 Sep 2022

@richard67 will that query work if I put it in an update sql

If so then I will create a PR with the query AND the ammended code to make sure they are removed on uninstall

avatar richard67
richard67 - comment - 7 Sep 2022

@richard67 will that query work if I put it in an update sql

If so then I will create a PR with the query AND the ammended code to make sure they are removed on uninstall

@brianteeman It will work with an update SQL, but an update SQL would not be the right place because if someone updates to a version so it is run and then later deletes the template, they have the problem again, and the update SQL will not run anymore because older than the database schema version.

I.e. the problem can happen at any time on any version, and not only at a particular version.

Therefore it should not be added to any update SQL script but to a procedure in script.php which runs at the end of each update.

Another possibility would be to add it to the database checker and fixer so it runs only if such a problem was detected, using a pre-defined check and update query similar to the utf8mb4 check we still have.

If that is the way to go, I would prefer that it's me who implements it because there are not many other people who know in detail how the database checker works.

avatar richard67
richard67 - comment - 7 Sep 2022

P.S.: But I won't have time before the weekend to do anything.

avatar brianteeman
brianteeman - comment - 7 Sep 2022

dont worry its a combination pr. #38714 just writing the test isnstructions

avatar richard67
richard67 - comment - 7 Sep 2022

P.P.S.: Of course if we can make sure the problem does not happen again, we can make an update SQL script which runs when updating to the version with that fix, and later we won't need it again. But as soon as the delete statement on template uninstallation fails for some reason, the problem will be back.

So maybe do a PR with both things now, and later when we implement the health check (was somewhere on the road map for a future version) we can add a check for that.

avatar richard67
richard67 - comment - 7 Sep 2022

dont worry its a combination pr. #38714 just writing the test isnstructions

@brianteeman Yes, we can do that. The PR looks ok to me.

avatar brianteeman
brianteeman - comment - 7 Sep 2022

Please test #38714

avatar richard67
richard67 - comment - 7 Sep 2022

Closing as having a pull request. Please test #38714 . Thanks in advance.

avatar richard67 richard67 - change - 7 Sep 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-09-07 17:53:56
Closed_By richard67
avatar richard67 richard67 - close - 7 Sep 2022

Add a Comment

Login with GitHub to post a comment