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

Error installing example plugin: Undefined constant Glpi\Plugin\Hooks::ADD_CSS_ANONYMOUS_PAGE #85

Open
Ange1GL opened this issue Mar 7, 2025 · 4 comments · May be fixed by #86
Open

Comments

@Ange1GL
Copy link

Ange1GL commented Mar 7, 2025

When cloning a repository that contains an example plugin and installing it on GLPI, an error occurs indicating that a required function for installation does not exist. Additionally, the following warning appears:

Image

Image

@joacoetche06
Copy link

I have this issue too:
[2025-03-18 18:23:25] glpiphplog.WARNING: *** PHP User Warning (512): Error while loading plugin example: Undefined constant Glpi\Plugin\Hooks::ADD_CSS_ANONYMOUS_PAGE in /home/joaco/glpi_10_17/src/Plugin.php at line 355
Backtrace :
src/Plugin.php:355 trigger_error()
src/Plugin.php:950 Plugin::load()
: Plugin->install()
src/Marketplace/Controller.php:546 call_user_func()
src/Marketplace/Controller.php:436 Glpi\Marketplace\Controller->setPluginState()
ajax/marketplace.php:83 Glpi\Marketplace\Controller->installPlugin()

@0xNath
Copy link

0xNath commented Mar 20, 2025

I confirm the issue, on a fresh instance of GLPI 10.0.18 I can't install this plugin.

I called get_included_files() in the "install" method of "src/Plugin.php", and the hooks file of the plugin is not present in the included files :

Array
(
[...]
    [242] => /var/www/glpi/plugins/example/setup.php
    [243] => /var/www/glpi/plugins/example/src/DeviceCamera.php
    [244] => /var/www/glpi/plugins/example/src/Example.php
    [245] => /var/www/glpi/src/Link.php
    [246] => /var/www/glpi/vendor/monolog/monolog/src/Monolog/DateTimeImmutable.php
)

@0xNath
Copy link

0xNath commented Mar 20, 2025

The plugin can't be installed because of those three lines in setup.php of the plugin 'example' :

$PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example']    = [ItemForm::class, 'preSection'];
$PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example']   = [ItemForm::class, 'postSection'];
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';

If you comment them you can install the plugin, they were added for the version 11 of GLPI.

@trasher
Copy link
Contributor

trasher commented Mar 21, 2025

Well, there are several distinct issues here.

Original one: Undefined constant Glpi\Plugin\Hooks::ADD_CSS_ANONYMOUS_PAGE is fixed updating to latest GLPI release.

*ITIL* hooks have been introduced in #62 - they exists only for GLPI v11
SET_ITEM_IMPACT_ICON has been added in #55 and also exists for GLPI v11.

You can remove calls as a workaround. I guess those should have been merged in a specific development branch instead of main, or should have been conditionned. Ping @stonebuzz @cedric-anne

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 a pull request may close this issue.

4 participants