Skip to content

Conversation

@cedric-anne
Copy link
Member

@cedric-anne cedric-anne commented Oct 16, 2025

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • This change requires a documentation update.

Description

To simplify the plugins source handling during a migration to a new intermediate/major version of GLPI, I propose to introduce a new marketplace:update_local_plugins command. This command will download, for every plugin present in the glpi_plugins table, the latest compatible version, unless the local version present on the filesystem is already up-to-date. This will be done for all plugins, even uninstalled/inactive plugins, as even an inactive plugin may completely break GLPI due to compile errors (see #18695). For all active plugins, il will then automatically execute the install and activate method, so every active plugins before the execution will be but back to their active state after the command execution.

Example of a migration script:

bin/console database:update --no-interaction
bin/console marketplace:update_local_plugins --no-interaction
bin/console plugin:resume_execution --no-interaction

This command could also be used as a scheduled routine to always get latest versions of plugins.

Screenshots (if appropriate):

First execution, right after a GLPI update, with an empty plugins directory:
image

Second execution, a few days later, to get latest updates:
image

@cedric-anne
Copy link
Member Author

cedric-anne commented Oct 16, 2025

@flegastelois I added the --username option to the command, as we have in the plugin:install command. I figured out that it requires to uses sessions on CLI context, and this is the latest place we do it. This has been initially made to handle the usage of $_SESSION['glpiactiveprofile'] in plugins install functions, but IMHO, the correct way to initialize profiles rights during plugins installation is to use the Migration::addRight() or Migration::giveRight() methods, as we do in GLPI migrations.
I removed the mandatory presence of this option from the plugin:install, and I think we should deprecate its usage in GLPI 11.1, or even now, to be able to remove it in the future.

@SebSept
Copy link
Contributor

SebSept commented Oct 17, 2025

is composer update triggered ?

@trasher
Copy link
Contributor

trasher commented Oct 17, 2025

is composer update triggered ?

Plugins releases are supposed to bring all their dependencies, like GLPI release archives.

Comment on lines +1189 to +1193
Session::addMessageAfterRedirect(
htmlescape(sprintf(__('Plugin %1$s prerequisites are not matching, it cannot be installed.'), $this->fields['name'])) . ' ' . $msg,
true,
ERROR
);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this error message will be lost in CLI context.
Maybe it should throw an exception for CLI?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are calls to $this->outputSessionBufferedMessages() in the commands, to handle these messages. This is how all plugins commands are made. I do not want to refactor these right now, but I agree it should use exceptions in the future.

parent::configure();

$this->setName('marketplace:update_local_plugins');
$this->setDescription(__('Download up-to-date sources for all local plugins and process updates of active plugins'));
Copy link
Member

Choose a reason for hiding this comment

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

"Download and update all plugins to their latest compatible versions, then reactivate active ones."

{
parent::configure();

$this->setName('marketplace:update_local_plugins');
Copy link
Member

Choose a reason for hiding this comment

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

"marketplace:update"

@flegastelois
Copy link
Member

I have some specific plugins enabled only on my workstation (that is, not available at all on the marketplace), and when the command runs, I get a message:

Plugin "xxxxxx" is not available for your GLPI version.

This message is not very clear; it should say, "This plugin does not exist on the marketplace," or something similar, more explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants