Hello there,
After upgrading drupal/anchor_link (1.7.0 => 2.1.0) on v8.8.2 PHP 7.3.8 logs show me following PHP Warnings:
Warning: Use of undefined constant ANCHOR_LINK_LIBRARY_PATH - assumed 'ANCHOR_LINK_LIBRARY_PATH' (this will throw an Error in a future version of PHP) in Drupal\anchor_link\Plugin\CKEditorPlugin\AnchorLink->getLibraryPath() (line 83 of /Users/robin-strasen/Documents/GitHub/geschke-hosting/web/modules/contrib/anchor_link/src/Plugin/CKEditorPlugin/AnchorLink.php)
Warning: Use of undefined constant ANCHOR_LINK_LIBRARY_PATH - assumed 'ANCHOR_LINK_LIBRARY_PATH' (this will throw an Error in a future version of PHP) in Drupal\anchor_link\Plugin\CKEditorPlugin\AnchorLink->getLibraryPath() (line 91 of /Users/robin-strasen/Documents/GitHub/geschke-hosting/web/modules/contrib/anchor_link/src/Plugin/CKEditorPlugin/AnchorLink.php)
Adding quotes to given var fixes this warning. Following patch can be used until this is fixed in one of the next releases.
Best
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3114343-8.patch | 2.88 KB | joelpittet |
Comments
Comment #2
r81d3r commentedComment #3
joelpittetThe patch is incorrect, the reason it's mentioning undefined is because it's defined in the
anchor_link.installfile which is only loaded in certain circumstances.I did a quick test and moving it to the module file is more likely to be available in more circumstances.
This will likely need a new release.
Comment #4
joelpittetAlso the file shouldn't be in the path name.
Comment #5
joelpittetAlso while debugging I noticed that
DRUPAL_ROOT, not the URL's path which failed to loadgetLibraryPathgets called a few times so the result should be static cachedComment #6
pookmish commentedI've just ran into this same issue. The patch works.
But personally i think a constant on the AnchorLink class would be more appropriate. Then the constant doesn't get added to the global scope and is only called when necessary.
Comment #7
joelpittetI agree, would you like to roll that patch or should I?
Comment #8
joelpittetHere's the Class constant replacement @pookmish
Comment #9
rajab natshahComment #11
rajab natshahCommitted ... Thank you Joël for patching the better way!
Thanks, r81d3r for reporting and Mike for following up
Comment #12
rajab natshahComment #13
rajab natshahComment #14
rajab natshahComment #15
rajab natshahComment #16
rajab natshahComment #18
rajab natshahRemoving constants as it will bring issues on
Trying to look at
https://git.drupalcode.org/project/drupal/commit/1edf15f
Comment #21
rajab natshahComment #22
rajab natshahComment #23
rajab natshahComment #24
rajab natshahPlanned to switch to use find from the LibrariesDirectoryFileFinder class
https://git.drupalcode.org/project/drupal/commit/1edf15f
When Drupal 8.9.x and Drupal 9.0.0 go out
But they still do have issues as getLibraryPath and getLibraryUrl. each will have it's used cases to check the phsical files and to call url link to images or + the origin Url -- removing language url ditection from the link to the image or js libraray.