Pending

User tests: Successful: Unsuccessful:

avatar eshiol
eshiol
13 Jul 2017

Pull Request for Issue #11490.
Awaiting Joomla 4.0 I suggest this solution

Summary of Changes

Joomla doesn't delete categories when uninstall a component. The user must manually delete them before uninstalling the component.

Testing Instructions

  1. Install a 3rd party extension that uses Joomla category manager.
  2. Create a category using that extesnsion.
  3. Uninstall the extension.
  4. Install the same extension again.
  5. We can see that the category gets deleted with that extension.
  6. Install the patch.
  7. Create a category using that extesnsion.
  8. Uninstall the extension.
  9. Install the same extension again.
  10. We can see that categories is still there.
avatar eshiol eshiol - open - 13 Jul 2017
avatar eshiol eshiol - change - 13 Jul 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Jul 2017
Category Libraries
avatar eshiol eshiol - change - 13 Jul 2017
The description was changed
avatar eshiol eshiol - edited - 13 Jul 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Nov 2017
Status Pending Needs Review
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Nov 2017

Status is set on "Needs Review".

avatar Bakual
Bakual - comment - 5 Nov 2017

Actually, I love the current behavior. When I uninstall an extension, I expect it to be removed completely and not leave orphaned data around.

Why do you want to remove it?

avatar brianteeman
brianteeman - comment - 22 Jul 2018

I am closing this as abandoned. There has been no comment or tests. It can always be re-opened if required

avatar brianteeman brianteeman - close - 22 Jul 2018
avatar brianteeman brianteeman - change - 22 Jul 2018
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2018-07-22 19:38:43
Closed_By brianteeman
avatar eshiol
eshiol - comment - 23 Jul 2018

Ok, but I think the behavior of the category manager is wrong. As said by @parthlawate:
The category manager is a 'horizontal' infrastructure component.. The categories in there are 'owned' by components.. so it's only logical that the owner of the categories decide on its deletion.. I don't think this should be a default behavior at all. We can provide a method that the component can use in its uninstall script if it needs to do a clean up

avatar Bakual
Bakual - comment - 23 Jul 2018

I never understood why you ever want to keep any data when you uninstall an extension.
As a user my expection certainly is that when I uninstall something, everything directly associated with it is deleted as well. I don't want to do any cleanups manually and I alwys hate it when extensions misbehave and leave orphaned stuff (data, libraries, whatever) behind.

avatar eshiol
eshiol - comment - 23 Jul 2018

Why you want delete any data when you uninstall an extension? :)
In many systems it is allowed to leave data after uninstalling a program for later use. Data deletion should be a choice left to the user.

Now, the delete data process, when an extension is uninstalled, is entrusted to two routines. The extension deletes its own data, the core (the category manager) deletes the categories. If the extension is not properly designed it could leave orphaned elements that you can not delete via Joomla.
If the category manager leaves the categories, as proposed by this PR, you can manually delete the data via Joomla by installing the extension later.

Imho, the extension, not the core, should delete its own data, including the categories. The extension should decide whether it should delete its data or not.

avatar alikon
alikon - comment - 23 Jul 2018

Why you want delete any data when you uninstall an extension? :)

cause i'm uninstalling it, otherwise what's the meaning of uninstall ?

avatar Bakual
Bakual - comment - 23 Jul 2018

The extension should decide whether it should delete its data or not.

No, it should always delete its data. There is no reason to keep it. ?

avatar mbabker
mbabker - comment - 23 Jul 2018

Well, there is an argument both ways. It is not uncommon for CMS extensions to support being uninstalled and re-installed re-using an existing data source/structure, and in those scenarios the uninstall process should NOT remove data. Therefore, us making an arbitrary decision at the core level to force removal of data breaks this concept.

avatar Bakual
Bakual - comment - 23 Jul 2018

It is not uncommon for CMS extensions to support being uninstalled and re-installed re-using an existing data source/structure, and in those scenarios the uninstall process should NOT remove data.

I'd argue that case is just lazyness of the extension developer who didn't write either the uninstall or update procedure correctly. I still don't see a reason for this usecase where you uninstall and reinstall the same extension. Why uninstall if you're going to install it again?

avatar mbabker
mbabker - comment - 23 Jul 2018

I don't agree that's either developer laziness or bad code to leave data behind on uninstall but personally I don't have an explicit use case for that workflow. Either way, it is not an uncommon thing for an extension to be able to support uninstall without forced data removal and I think the most that our API should do is have a hook in the installer library where a developer can trigger a removal behavior if desired/required, it should not be an arbitrary decision forced by the framework.

avatar ggppdk
ggppdk - comment - 23 Jul 2018

If you uninstall a program in windows , many of them will ask about deleting the settings or data + settings,

  • and majority of them will not even ask about data ! they would just keep the data !

In any case let's get back to Joomla,

Let's say that your extension is giving you the option to keep the data,

  • but wait, the above will not include the categories , because Joomla uninstaller will just delete them

I understand that categories are special case because they are in a shared (among extensions table), but this locked down behavior is problematic

At least this could be fixed in J4

but I also understand this,
if extensions become responsible for cleaning up the categories table,

  • then some of them might damage initially, ok it will be a bug that they will have to fix

[EDIT]
i mean not calling rebuild or a bug like not adding extra code to delete the categories themselves

avatar brianteeman
brianteeman - comment - 23 Jul 2018

Many many years ago when Joomla didnt have the ability to update an extension it was useful if the data was not removed because the only way to update an extension was to uninstall and then to reinstall the new version.

That isnt true any more.

If Joomla doesnt remove the data when you remove an extension then there is no way to remove it except by directly in the database which surely cannot be desirable.

avatar mbabker
mbabker - comment - 23 Jul 2018

Remember too, there are extensions when dealing with major upgrades (either of their own code or Joomla releases, because they do a different code base or distributable for each of our major versions) that will have a "completely uninstall old version and install new version" workflow. In those cases, arbitrary data removal would be a bad thing. How many of those extensions actually exist, or how many integrate into core services where this could be a problem (categories, menus, possibly tags or content versioning) is unknown but just flat out saying "core uninstall will nuke all your data, end of discussion" is IMO the wrong message.

Yes, in a state of nirvana one could hit the uninstall button and it would be like the extension was never installed to begin with. No, we simply do not live in that state and need to be a little flexible here.

avatar brianteeman
brianteeman - comment - 23 Jul 2018

I am not sure when the code to remove categories was added but this has been a reported issue since at least Aug 2016 -so are we really talking about a general issue ?

avatar brianteeman
brianteeman - comment - 23 Jul 2018

Remember that no one had commented or tested this PR since it was submitted exactly a year ago. No one was interested at all until it was closed so I really dont think there is a real issue to solve

avatar mbabker
mbabker - comment - 23 Jul 2018

It's a general issue as it relates to how extensions interface with other horizontal content components (categories and tags right now, in theory com_finder and its index too).

I really dont think there is a real issue to solve

No, there aren't people beating down our doors saying that the current behavior is problematic. I am saying though that the framework forcing the current behavior is less than optimal and I think the correct resolution is removing the forced data removal as this pull request does and exposing a hook point in Joomla\CMS\Installer\InstallerScript that can be called on uninstall to remove this data (hell make it default enabled so an extension has to turn it off if you really want to have an opinion on the matter). Conceptually the same would need to exist for the #__eem_contentitem_tag_map table to clear out relations for the tags component, and something to deal with the Smart Search index (that one might just need to be an alert after uninstall finishes saying "you should re-index your data" since it can be trickier to correctly deal with removing a bulk of data like that).

Or, make it a JED requirement that an uninstall has to leave the site as pure as if the extension never existed and force every developer to change their workflow so that "uninstall and reinstall without data loss" is NEVER an option under any circumstances (and see how well that one is received).

avatar Bakual
Bakual - comment - 23 Jul 2018

If you really want to go that route, then removal should be the default behaviour and keeping the data an explicit choice of the developer.
Is the category the only thing Joomla automatically cleans up? Associations, ucm stuff, content types comes to mind, not sure if Joomla does anything there (I do it in my uninstall SQL anyway). For modules there is also the #__modules and #__modules_menu tables and of course #__assets if you do anything with permissions.
Imho Joomla should clean anything, but I know that when it comes to content types, it's not so easy to do automatically.

avatar mbabker
mbabker - comment - 23 Jul 2018

Is the category the only thing Joomla automatically cleans up?

Nope. If you expand the code diff in both directions a component uninstall right now removes all ACL data, the database schema tracking, categories, and updates. Of those, only updates are really safe to kill off as those can be easily restored. Losing the database schema tracking means a follow-on update of the extension would replay all schema changes and could cause issues depending on what's in those deltas (and becomes more problematic if the GSoC project which makes the database fix routine accessible in the extension manager for all extensions merges in). Losing the ACL data is, well, not that good if you've got restricted access content.

avatar mbabker
mbabker - comment - 23 Jul 2018

To be clear here I don't think that it's an issue that Joomla does cleanup by default. I just think it gives a bit more flexibility to everyone if it is possible for an extension to turn off this cleanup.

avatar Bakual
Bakual - comment - 23 Jul 2018

To be clear here I don't think that it's an issue that Joomla does cleanup by default. I just think it gives a bit more flexibility to everyone if it is possible for an extension to turn off this cleanup.

I can get behind that. If it's optional to keep the data. But then it should be a behavior toggle for all aspects, not only categories. Otherwise it will only create more issues.

avatar alikon
alikon - comment - 23 Jul 2018

Yes, in a state of nirvana one could hit the uninstall button and it would be like the extension was never installed

i shuold really stop to use drugs ?

avatar laoneo
laoneo - comment - 23 Jul 2018

At the end of the day it needs to be consistent in core. For example the custom fields are not deleted when an extension is uninstalled and also not the menu items. So whatever comes out in this discussion we need to have one way of behavior.

avatar Bakual
Bakual - comment - 23 Jul 2018

Menuitems I can understand to a degree, as deleting the menuitems can have an impact on SEO and possibly break site structure when you delete them. And of course you can change an existing menuitem to point to another component easily.

As for custom fields, yes those should be deleted as well. But here is the same issue as with any content type related data. The uninstaller would have to know the content types for a given component and I don't think it knows that.

avatar parthlawate
parthlawate - comment - 24 Jul 2018

I agree there should be consistency.. However only the data 'owner' should decide if their data should be kept or removed. This can be flag in the uninstall methods called by extensions.. This can apply to all Horizontals - Categories, Custom fields... In case of Menus we could un publish the menus.. However since this PR is purely about categories , should we not conclude on that aspect ?

avatar Bakual
Bakual - comment - 24 Jul 2018

This PR certainly is wrong as it keeps the data without any conditional at all.
So if someone wants to create a PR where the extension (or even better the user) can decide whether to delete the data or not, that could be considered then.

avatar laoneo
laoneo - comment - 24 Jul 2018

If we go that way, then we need to do it properly and ask the admin if the data should be deleted after uninstall and not the extension developer. There is no reason to let the extension dev decide, because then we have inconsistency again, some extensions will do it one way and some the other.

avatar infograf768
infograf768 - comment - 24 Jul 2018

Note: there are other cases where some data may or may not have to be deleted, depending on the admin decision.
For example, on a multingual site, if the admin deletes a Content Language.

Add a Comment

Login with GitHub to post a comment