InvalidLibraryDependencyException causes the following PHP fatal error when interpreted (e.g., when scanning for deprecated code use):

Fatal error: Trait method getLibrary has not been applied, because there are collisions with other trait methods on Drupal\libraries\ExternalLibrary\Exception\InvalidLibraryDependencyException in /var/www/docroot/modules/contrib/libraries/src/ExternalLibrary/Exception/InvalidLibraryDependencyException.php on line 13

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TravisCarden created an issue. See original summary.

Berdir’s picture

That's not the only issue, if you fix that, then you run into:

( ! ) Fatal error: Cannot declare interface Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorIdInterface, because the name is already in use in modules/contrib/libraries/src/ExternalLibrary/Utility/LibraryIdAccessorInterface.php on line 8

Apparently the name of either the class or the interface is wrong.

jefuri’s picture

Renamed the getLibrary for the dependency trait to getDependency within the exception.

amitgoyal’s picture

Status: Needs review » Needs work

I am still getting this error,

➜  d9 git:(8.8.x) ✗ ./vendor/mglaman/drupal-check/drupal-check --drupal-root=./ modules/contrib/libraries

 23/90 [▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░]  25%
Fatal error: Trait method getLibrary has not been applied, because there are collisions with other trait methods on Drupal\libraries\ExternalLibrary\Exception\InvalidLibraryDependencyException in libraries/src/ExternalLibrary/Exception/InvalidLibraryDependencyException.php on line 13
milindk’s picture

Attaching the patch to solve the above issue. The issue is with the same function name (getLibrary()) and the same function is required to implement by class InvalidLibraryDependencyException is getting in both the traits.

Either solution will be to make use of only one trait or use the patch method to solve it.

milindk’s picture

Status: Needs work » Needs review
milindk’s picture

A small mistake in patch..attaching again.

milindk’s picture

amitgoyal’s picture

Status: Needs review » Reviewed & tested by the community

#9 looks good to me.

  • podarok committed 0b4cc06 on 8.x-3.x authored by milindk
    Issue #3039243 by milindk, jefuri, TravisCarden, amitgoyal, Berdir:...
podarok’s picture

Status: Reviewed & tested by the community » Fixed

Thank you

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.