Skip to content

Conversation

@RomainLvr
Copy link
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • Here is a brief description of what this PR does

Problem:
After migrating to GLPI 11, uninstalling the GenericObject plugin fails with UndefinedMethodError when trying to call uninstall() on Custom Asset classes that don't have this method.

[2025-11-10 10:35:42] glpi.CRITICAL:   *** Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\UndefinedMethodError: "Attempted to call an undefined method named "uninstall" of class "Glpi\CustomAsset\inventaireAsset"." at hook.php line 95
  Backtrace :
  ./marketplace/genericobject/hook.php:95            
  ./src/Plugin.php:1095                              plugin_genericobject_uninstall()
  :                                                  Plugin->uninstall()
  ./src/Glpi/Marketplace/Controller.php:670          call_user_func()
  ./src/Glpi/Marketplace/Controller.php:577          Glpi\Marketplace\Controller->setPluginState()
  ./ajax/marketplace.php:66                          Glpi\Marketplace\Controller->uninstallPlugin()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70                              Symfony\Component\HttpKernel\Kernel->handle()

Root cause:
GenericObject items are migrated to native GLPI Custom Assets (Glpi\CustomAsset\* namespace) which don't implement the uninstall() method.

Solution:
Add method_exists() check before calling uninstall() in hook.php to handle both legacy GenericObject classes and new Custom Assets.

@RomainLvr RomainLvr self-assigned this Nov 10, 2025
Copy link
Contributor

@Rom1-B Rom1-B left a comment

Choose a reason for hiding this comment

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

Please update CHANGELOG

@RomainLvr RomainLvr requested a review from Rom1-B November 10, 2025 15:25
@Rom1-B Rom1-B merged commit 7de0141 into main Nov 12, 2025
3 checks passed
@Rom1-B Rom1-B deleted the fix/uninstall-custom-assets-method-check branch November 12, 2025 07:07
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.

4 participants