Skip to content

Fix(plugin): deduplicate plugin directories list#23468

Draft
Mary-Clb wants to merge 1 commit intoglpi-project:11.0/bugfixesfrom
Mary-Clb:fix/deduplicate-plugin-directories
Draft

Fix(plugin): deduplicate plugin directories list#23468
Mary-Clb wants to merge 1 commit intoglpi-project:11.0/bugfixesfrom
Mary-Clb:fix/deduplicate-plugin-directories

Conversation

@Mary-Clb
Copy link
Contributor

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !42478
  • Prevents duplicate plugin directory processing and related side effects (such as duplicate hook/search option registrations) when directory entries are repeated.

protected static function getPluginDirectories(): array
{
return GLPI_PLUGINS_DIRECTORIES;
return array_values(array_unique(GLPI_PLUGINS_DIRECTORIES));
Copy link
Contributor

Choose a reason for hiding this comment

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

There are several places where GLPI_PLUGINS_DIRECTORIES is called directly without going through this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

It sounds strange there are duplicates in this kind of constant definition. If issue is confirmed; it probably must be fixed at the declaration.

Copy link
Contributor

Choose a reason for hiding this comment

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

By default, we have:

'GLPI_MARKETPLACE_DIR' => $this->root_dir . '/marketplace',
'GLPI_PLUGINS_DIRECTORIES' => [
    '{GLPI_MARKETPLACE_DIR}',
    $this->root_dir . '/plugins',
],

However, if in locale_define.php it is written:

define('GLPI_MARKETPLACE_DIR', GLPI_ROOT . '/plugins');

GLPI_PLUGINS_DIRECTORIES has the same value twice.

Copy link
Contributor

@trasher trasher Mar 13, 2026

Choose a reason for hiding this comment

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

In this case the local_define is bad.
But anyway; rather than trying to dedup everywhere the constant is used, the fix must be done at its instanciation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants