Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow packages to declare that their child extensions cannot be uninstalled #13154

Merged
merged 4 commits into from
Dec 13, 2016
Merged

Allow packages to declare that their child extensions cannot be uninstalled #13154

merged 4 commits into from
Dec 13, 2016

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Dec 10, 2016

Pull Request for Issue #12976 and #13151

Summary of Changes

This will allow a package to declare in its XML manifest that child extensions cannot be uninstalled separately and implements the checks to block this behavior. It also removes the check in the extension manager which prevents language extensions from being uninstalled separately.

To accomplish this, a new <blockChildUninstall> tag is supported and should provide a value that translates to a PHP boolean. The default behavior is <blockChildUninstall>0</blockChildUninstall> which is consistent with the existing behavior since there is no lookup in place. When set to 1 or true, this will block child elements from being removed.

Testing Instructions

Alter a package extension's manifest to include the new tag and test the uninstall behaviors of its individual extensions. This will rely on a successful install that registers the parent package ID to the database as implemented earlier.

Documentation Changes Required

  • Document the new tag in docs covering package extension manifests
  • Update https://github.com/joomla/schemas with the new tag if we are still maintaining these schemas

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-staging labels Dec 10, 2016
@andrepereiradasilva
Copy link
Contributor

andrepereiradasilva commented Dec 10, 2016

one general comment shouldn't the pkg_en-GB manifest have this new xml tag <allowChildUninstall>0</allowChildUninstall>?
https://github.com/joomla/joomla-cms/blob/staging/administrator/manifests/packages/pkg_en-GB.xml

// Does this extension have a parent package? If so, check if the package disallows individual extensions being uninstalled
if ($this->extension->package_id)
{
if (!$this->canUninstallPackageChild($this->extension->package_id))
Copy link
Contributor

@andrepereiradasilva andrepereiradasilva Dec 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small thing, but couldn't this be reduced to just one if?

if ($this->extension->package_id && !$this->canUninstallPackageChild($this->extension->package_id))

the same for the others.

@andrepereiradasilva
Copy link
Contributor

hum tested with weblinks latest beta (just adding <allowChildUninstall>0</allowChildUninstall> to pkg_weblinks.xml file and ziping again) and didn't seem to work. i was able to uninstall every extensions of the component without uninstalling the package.
image

@infograf768
Copy link
Member

infograf768 commented Dec 11, 2016

Did not add to a lang pack the new tag <allowChildUninstall>
Tested both languages which have been installed as packs before #12977 and after.
In both cases, trying to delete a site or an admin language is not permitted and instead of the clear message we got before or the new string, we now get Error uninstalling language.

Then I added <allowChildUninstall>1</allowChildUninstall> in the lang pkg, zipped it and installed.
Tried to delete a site or admin language and could not. Same message.

Changed to <allowChildUninstall>0</allowChildUninstall> and same result.

@infograf768
Copy link
Member

Concerning language packs, another change as to be done in the model:
See https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_installer/models/manage.php#L234
By taking off && $row->type != 'language', I now can uninstall a language.

But <allowChildUninstall>0</allowChildUninstall> still does not work.

@Bakual
Copy link
Contributor

Bakual commented Dec 11, 2016

I think the whole approach is flawed here.
First I think using an allowChildUninstall tag is the wrong way. Since that is the default behavior I would expect a blockChildUninstall tag instead. It's a bit counterintuitive when you have to add allowChildUninstall="0" to change the behaviour.

But more importantely I don't think it makes sense to have that tag in the package. I think it's a very rare case that you don't want to allow any subpackage to be uninstalled. More often you just want to prevent eg the library or the component to be uninstalled. But the modules and plugins for example are fine to be uninstalled in most cases.

As for the language packs (where this request likely comes from), we're trying to solve the issue from the wrong end. It origins from the fact that you can't reinstall an already installed language from the language installer. Allow that (instead of hiding, show the language as installed and show a "reinstall" button) and you no longer need to block uninstalling language subpacks.
I can do that PR.

@infograf768
Copy link
Member

infograf768 commented Dec 11, 2016

In the mean while my test show here that the culprit comes from

public $allowChildUninstall = true;

if I take off this, then I can prevent an extension from being uninstalled.

@infograf768
Copy link
Member

As for the language packs (where this request likely comes from), we're trying to solve the issue from the wrong end. It origins from the fact that you can't reinstall an already installed language from the language installer. Allow that (instead of hiding, show the language as installed and show a "reinstall" button) and you no longer need to block uninstalling language subpacks.

Agree. I still think that one should not be able to uninstall a language pack site or admin lang without the possibility to reinstall.
I am also concerned about multilingual sites where one would, by mistake, uninstall the site lang and thus breaking the site without knowing it, except by the multilangstatus module.

@andrepereiradasilva
Copy link
Contributor

andrepereiradasilva commented Dec 11, 2016

@Bakual we could use the locked as proposed in #13037 for that.

But this pr is about child parent relation so imo a diferent thing.

@Bakual
Copy link
Contributor

Bakual commented Dec 11, 2016

Agree. I still think that one should not be able to uninstall a language pack site or admin lang without the possibility to reinstall.

Exactly that. As long as you can not reinstall the language from the language manager, we have to prevent uninstalling it partially. I haven't looked at it yet but I think it should be simple to add a reinstall button in that list. Just need time to do it 😄

I am also concerned about multilingual sites where one would, by mistake, uninstall the site lang and thus breaking the site without knowing it, except by the multilangstatus module.

They can also break their site by uninstalling the whole language pack and by doing a lot of other stupid stuff. You can't prevent them from doing stupid things. As long as we don't prevent them from fixing it again, I have no issues with that.

we could use the locked as proposed in #13037 for that.

Nah, locked is a different thing. It applies to specific core extensions which should not be able to be uninstalled. This here would be for 3rd party stuff. You would have to make that locked state a conditional ("only allow uninstalling if all other extensions of this package are uninstalled as well").

@mbabker
Copy link
Contributor Author

mbabker commented Dec 11, 2016

I'm not making a language package specific fix, I'm trying to create something generally usable for package extensions in general. If you want a language specific fix then feel free to implement it.

But more importantely I don't think it makes sense to have that tag in the package. I think it's a very rare case that you don't want to allow any subpackage to be uninstalled. More often you just want to prevent eg the library or the component to be uninstalled. But the modules and plugins for example are fine to be uninstalled in most cases.

It is up to the distributor to decide that behavior. The current behavior we have a need for is to disallow all children of a package to be uninstalled. If you feel you have a more suitable alternative please propose it.

@mbabker
Copy link
Contributor Author

mbabker commented Dec 11, 2016

Fixed the bugged behavior with the manifest object's instantiation keeping things from working right and changed the tag name to blockChildUninstall. Added it to the English package manifest.

@Bakual
Copy link
Contributor

Bakual commented Dec 11, 2016

I'm not making a language package specific fix, I'm trying to create something generally usable for package extensions in general.

If you have a usecase beside the language pack, then I'm fine with it.

changed the tag name to blockChildUninstall.

Thanks 👍

@mbabker
Copy link
Contributor Author

mbabker commented Dec 11, 2016

Personally, I don't. However, we have a very explicitly hardcoded behavior in core right now which doesn't allow individual language packages to be uninstalled; you have to uninstall the package. So if you do something like a discover install (which is what the initial issue report was anyway), you won't have a package extension installed so you can't uninstall the discovered languages.

So, the hardcoded "special" handling for language extensions is removed from the extension manager's MVC layer and integrated into the install adapters as a configurable behavior, creating a side effect of allowing developers to also do the same with their package extensions if they so choose.

@infograf768
Copy link
Member

It works OK now for that PR. We still need the reinstall possibility as @Bakual rightfully wrote as otherwise this is no use for languages, causing more issues than fixes.

Remains also to decide what will be our policy for lang packs:
Do we let the TTs individually choose or not to implement the new feature preventing from uninstalling uniquely site or admin lang?
I know I would prefer my French pack to have <blockChildUninstall>true</blockChildUninstall> if this is merged.

Question, unrelated to this PR:
It gives here :

The Frenchfr-FR extension is part of a package which does not allow individual extensions to be uninstalled.
The parenthesis have disappeared for my French site and admin extension name which are French (fr-FR), while they show well for en-GB.
screen shot 2016-12-11 at 18 28 35
Any idea about that?

@mbabker
Copy link
Contributor Author

mbabker commented Dec 11, 2016

Never claimed this was a "complete" thing for languages, and actually that's a feature above and beyond what I've been working on.

As is, we are in a better shape overall for languages and have given some new features to extension developers. Rightfully the hardcoded handling of languages in the uninstall process has been removed and that logic incorporated into the install routine itself. Fixing the bug originally reported about language extensions not being able to be uninstalled unless you remove the package (which if your install process didn't include it for whatever reason meant it couldn't be removed without FTP and database access).

Please don't let that lack of reinstall be a block to this. IMO it's unrelated and the situation neither improves or worsens with this PR.

@infograf768
Copy link
Member

@mbabker
i think this patch is real fine and would not block it at all ( I have anyway no power to block anything 😸 )

indeed allowing or not languages to prevent uninstalling site or admin parts is independant from this.

@Bakual
Copy link
Contributor

Bakual commented Dec 11, 2016

@infograf768 If you can reinstall the language, then you don't need this PR at all (for languages) anymore. It would be absolutely fine to allow users to uninstall languages partially.

Please don't let that lack of reinstall be a block to this. IMO it's unrelated and the situation neither improves or worsens with this PR.

It's indeed unrelated.

@infograf768
Copy link
Member

infograf768 commented Dec 12, 2016

I see no reason for any user to uninstall partially a language which has been installed by a registered pack. If someone wants to play with discover and expect the same behavior (almost) as in 1.5, then it is fine grace to this PR. For usual core packs I recommend anyway to use the new tag <blockChildUninstall>true</blockChildUninstall>

@mahagr
Copy link
Contributor

mahagr commented Dec 12, 2016

👍

Though... Wouldn't it make sense to add xml attribute which would allow to override the global setting:

<file type="plugin" group="system" id="gantry5" enabled="1" uninstall="0">plg_system_gantry5.zip</file>

I'm not sure if there's a way to enable a plugin by default either -- right now it looks like I'm doing it manually during postflight.

@mbabker
Copy link
Contributor Author

mbabker commented Dec 12, 2016

Feel free to send a PR after this one to add attributes for a per-extension basis. I'm cutting back contributions after my current backlog has cleared.

@infograf768
Copy link
Member

I have tested this item ✅ successfully on 9ac5354


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13154.

@mahagr
Copy link
Contributor

mahagr commented Dec 12, 2016

@mbabker Ack. I'll add it to my todo list.

@andrepereiradasilva
Copy link
Contributor

I have tested this item ✅ successfully on 9ac5354


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13154.

@jeckodevelopment
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13154.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Dec 13, 2016
@jeckodevelopment jeckodevelopment added this to the Joomla 3.7.0 milestone Dec 13, 2016
@rdeutz rdeutz merged commit 3734f75 into joomla:staging Dec 13, 2016
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Dec 13, 2016
@mbabker mbabker deleted the block-individual-package-uninstall branch January 29, 2017 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants