I am having difficulty with the libraries module after upgrading to Drupal 10. When I upgrade on my local without a full build (just upgrading using the existing db) I get the following on some admin pages:

Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations() in libraries_info() (line 407 of modules/contrib/libraries/libraries.module).

When I run the build through ci, I get this right after libraries installs during setup-app:

[error] TypeError: Drupal\Component\DependencyInjection\ReverseContainer::generateServiceIdHash(): Argument #1 ($object) must be of type object, null given in Drupal\Component\DependencyInjection\ReverseContainer->generateServiceIdHash() (line 87 of /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php) #0 [internal function]: Drupal\Component\DependencyInjection\ReverseContainer->generateServiceIdHash()
#1 /mnt/tmp/local.prod/source/docroot/core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php(75): array_map()
etc.... truncated

When I tried blt drupal:install on my local, I got the same exact result.

Comments

loopy1492 created an issue. See original summary.

loopy1492’s picture

Issue summary: View changes
loopy1492’s picture

Issue summary: View changes
loopy1492’s picture

Title: Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations() in libraries_info() » D10 Regression: Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations() in libraries_info()
Related issues: +#3337606: Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations() in find_existing_views_data_tables(), +#3323148: Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations() in xmlsitemap_check_status()
loopy1492’s picture

I started working on this but I am NOT confident enough in the workings of this module to make any contributions at this time. For now, we will disable the module.

Here is what I have so far. It seemed to stop the error but I don't know if it messed anything else up. I just started changing things; I didn't delve into the guts of how it all works. Someone who knows what they are doing needs to fix this instead.

    $libraries = [];
    $hook = 'library_info';
    // Gather information from hook_library_info().
    $module_handler = \Drupal::service('module_handler');
    $libraries = $module_handler->invokeAllWith($hook, function (callable $hook, string $module) {
      foreach ($this->invoke($module, $hook) as $machine_name => $properties) {
        $properties['provider'] = $module;
        $libraries[$machine_name] = $properties;
      }
    });
loopy1492’s picture

Issue summary: View changes
bmustafa’s picture

i am getting this error too:

[29-Apr-2023 05:48:58 Asia/Dubai] Uncaught PHP Exception Error: "Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations()" at D:\wamp64\www\seo_saja_drupal_backoffice\web\modules\contrib\libraries\libraries.module line 407

the module is not usable at this stage.

the above code suggestion did not work for, despite error gone, but the module does not function

willempje2’s picture

Take a look at: https://www.drupal.org/project/libraries/issues/3342032
Seems to be same problem.

loopy1492’s picture

joseph.olstad’s picture

Status: Active » Closed (duplicate)

If you notice this, please upgrade to libraries version 4.0.3 or newer

see
#3342032: Undefined method getImplementations()

joseph.olstad’s picture

ashetkar’s picture

Issue still exits in https://www.drupal.org/project/libraries/releases/4.0.3 module version.

error] TypeError: Drupal\Component\DependencyInjection\ReverseContainer::generateServiceIdHash(): Argument #1 ($object) must be of type object, null given in Drupal\Component\DependencyInjection\ReverseContainer->generateServiceIdHash() (line 87 of /home/vsts/work/1/s/docroot/core/lib/Drupal/Component/DependencyInjection/ReverseContainer.php) #0 [internal function]: Drupal\Component\DependencyInjection\ReverseContainer->generateServiceIdHash

joseph.olstad’s picture

@ashetar please open a new issue to report the steps to reproduce. You might want to try: remove the modules/contrib folder and re-run composer install to make sure that your files are 100% in sync with the expected version 4.0.3. Then rebuild caches and re-test

ashetkar’s picture

alfattal’s picture

@joseph.olstad I'm having the same issue. I've tried removing modules/contrib and following your suggested steps but that didn't help and I'm still getting the same error message.

joseph.olstad’s picture

this is likely caused by one of your contrib modules that needs to be upgraded , the module may provide a library, or the library it'self may need to be upgraded.

Prior to upgrading to Drupal 10 you should use the upgrade_status module to display a report about your compatibility

You may also need to scan your custom modules using the scanning tool included with upgrade_status

drush us-a mymodulename

joseph.olstad’s picture

What you can do is use this debugging technique and look at the stack of calls, look for module names and library names involved.

look at the comments on this page, explains a bit , put the debug right in the file that is throwing the error.

https://www.php.net/manual/en/function.debug-print-backtrace.php

joseph.olstad’s picture

rakshith.thotada’s picture

I think if you have exported libraries config to default folder -> libraries.settings.yml - Delete it and setup in CI should work fine.
This I tried after a lot of iteration. Finally it worked

Also after libraries module installation - reexport the config