Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#9 | 3039243-9-fatal-error-trait-method-getLibrary.patch | 841 bytes | milindk |
| |||
#8 | 3039243-6-fatal-error-trait-method-getLibrary.patch | 829 bytes | milindk |
#4 | libraries-trait_method_getlibrary_has_not_been_applied-3039243-4.patch | 715 bytes | jefuri |
|
Comments
Comment #2
BerdirThat'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.
Comment #3
TravisCarden CreditAttribution: TravisCarden at Acquia commented@Berdir, I believe that issue is fixed in #2882709: Misnamed interface causes "Fatal error: Cannot declare interface Drupal\libraries\ExternalLibrary\Utility\LibraryAccessorIdInterface"
Comment #4
jefuri CreditAttribution: jefuri as a volunteer and at Synetic commentedRenamed the getLibrary for the dependency trait to getDependency within the exception.
Comment #5
amitgoyal CreditAttribution: amitgoyal at Acquia commentedI am still getting this error,
Comment #6
milindk CreditAttribution: milindk as a volunteer and at Acquia commentedAttaching 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.
Comment #7
milindk CreditAttribution: milindk as a volunteer and at Acquia commentedComment #8
milindk CreditAttribution: milindk as a volunteer and at Acquia commentedA small mistake in patch..attaching again.
Comment #9
milindk CreditAttribution: milindk as a volunteer and at Acquia commentedSolve issue with PHPlint. Ref: https://www.php.net/manual/en/language.oop5.traits.php#language.oop5.tra...
Comment #10
amitgoyal CreditAttribution: amitgoyal at Acquia commented#9 looks good to me.
Comment #12
podarokThank you