Closed tsteur closed 3 weeks ago
Hi @tsteur, thanks for the PR. Have you by chance seen https://github.com/matomo-org/matomo/pull/22640? There's a reasonable community PR for this already in progress, and it's also linked from the issue.
Didn't see it! So sorry about that. Feel free to merge the other one if that's looking all good. Note: Need to make sure to check for config file being writable etc and to get proper error message when trying to install/update a premium feature without valid license.
Also should use DI there for there PluginInstaller
.
In case the person doesn't make the adjustments, can still look at this one.
@tsteur what do you mean DI?
Just checked my implementation and, indeed, when I try to install a paid plugin I get
Incompatible archive: PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature
I'll reuse your code of 422158b, thanks!
Also, do we really need to check that the config file is writable? I've had no errors with that.
what do you mean DI?
I mean dependency injection with that. Basically below so that other plugins can hook into the "PluginInstaller" as required:
$installer = StaticContainer::get(PluginInstaller::class);
Re config check: I've added because that's also what we're doing in https://github.com/matomo-org/matomo/blob/5.2.0-b4/plugins/Marketplace/Controller.php#L465 in the user interface and wanted to match this behaviour. Unsure if it's 100% needed, just wanted to play it safe.
what do you mean DI?
I mean dependency injection with that. Basically below so that other plugins can hook into the "PluginInstaller" as required:
$installer = StaticContainer::get(PluginInstaller::class);
Re config check: I've added because that's also what we're doing in https://github.com/matomo-org/matomo/blob/5.2.0-b4/plugins/Marketplace/Controller.php#L465 in the user interface and wanted to match this behaviour. Unsure if it's 100% needed, just wanted to play it safe.
Oh my bad, I thought it was some component on your codebase 😅
Description:
fix https://github.com/matomo-org/matomo/issues/21003
Adds a new command
marketplace:install-or-update-plugin
to install or update a plugin from Marketplace.Kept it consistent with
plugin:activate/deactivate
usage and output but decided to go for themarketplace
namespace in the command name so it's more clear it'll download it rather than installing a plugin from a local zip file (which aplugin:install
command might do). Could rename it though. In any case the command will only work if the Marketplace plugin is installed and activated.Example usage:
An error will be shown if plugin does not exist or no version is compatible or if directories aren't writable.
Additional fix
Added a check if the file is downloadable. If not, an error message will be shown. This happens when eg trying to install or update a premium feature but the license is missing or expired. Without this fix, it would just show a random error message that ZIP file failed to extract.
Review