When the core locale module is enabled, trying to load a page with a CKEditor and the anchor_link plugin enabled result in a crash :
Exception: Only local files should be passed to _locale_parse_js_file() (line 1129 of core/modules/locale/locale.module)
Downgrading to 2.0.0-alpha2 solves the issue as a workaround.
How to reproduce :
- Install anchor_link and all related libraries
- Enable locale module
- Try to access a page with a CKEditor, results in a crash
It seems to be related with the "getLibraryUrl()" function of the AnchorLink class as it returns an absolute URL with http scheme and it is not allowed by _locale_parse_js_file().
It seems major to me as updating this module breaks any multilingual website.
Comments
Comment #2
r81d3r commentedI experienced the same issue on a system with enabled locale module under the current 2.2.0 version of anchor_link.
I could get the plugin to work by cutting
out of
to get a local path. I can now use the anchor_link plugin 2.2.0 with enabled locale module and recieved no errors so far.
You can test my changes by using the patch provided in my post.
edit: This can be only seen as a first approach cause it leads to following Warning after Cache clear in logs:
Comment #3
r81d3r commentedThe warning
seems to be caused when
$originUrl = \Drupal::request()->getBaseUrl();results empty.Adding an if statement
seems to solve the problem by removing the first slash of the path if $originUrl results empty.
This can be tested with my _v2 patch.
Comment #4
mandus.cz commentedYour patch (v2) works. Thank you.
Comment #5
mandus.cz commentedComment #6
rajab natshahThanks a lot, lasensio for reporting,
Thank you r81d3r for the patch!
Having the following in getLibraryUrl()
There are two functions getLibraryUrl() and getLibraryPath()
Troubleshooting the issue
Comment #7
oleksandr yushchenko commentedFixed to use getLibraryPath() instead of getLibraryUrl()
Comment #8
oleksandr yushchenko commentedComment #9
oleksandr yushchenko commentedOne more with better implementation of getLibraryPath()
Comment #10
rajab natshahThanks Oleksandr for the patch
The full test for this change could be CKEditor settings + use in a text format
- Single language Drupal 8.8.2 + settings ( can you see the icons)
- Multi-language Drupal 8.8.2 + settings ( can you see the icons)
- Saving settings in default language.
- Saving settings in other languages.
- Editing in Default language.
- Editing in other languages.
For sure we should have an automated test. Be sure that all scenarios are working in the right way. ( in a new issue )
Comment #11
rajab natshahFollowing with #3087583: Drupal 9 compatibility for [CKEditor Anchor Link] with Drupal coding standard and practice
and #3114086: Drop support for [Libraries API] module. And move the logic to Drupal core 8.9.x libraries finding way
Comment #12
rajab natshahText formats and editors No Error when "Language", "Interface Translation", "Content Translation", "Configuration Translation" are disabled
Text formats and editors No Error when "Language" enabled
Text formats and editors Error When "Interface Translation" and "Language" enabled
https://api.drupal.org/api/drupal/core%21modules%21locale%21locale.modul...
Comment #13
oleksandr yushchenko commentedWhen debugging, current approach with getLibraryUrl() generates absolute path to link plugin.js (https://test.com/libraries/link/plugin.js), while other libraries have relative path, also looking into 2.1 branch previously getLibraryPath() was used. So patch #9 will fix this issue and not impact icons as they using getLibraryUrl
Comment #14
rajab natshahComment #15
rajab natshahThank you Oleksandr, got that after having a look at your patch
The following was committed in Drupal 8.9.x branch and it will be in Drupal 9.x branch too
https://git.drupalcode.org/project/drupal/commit/1edf15f
#3110305: Drupal 8.9.x deprecation signposting
#3096648: Add support for third party libraries in site specific and install profile specific libraries folders
Support for third party libraries in site specific and install profile specific libraries folders
Comment #17
rajab natshahCommitted ... Thank you :)
Using the new core logic and order untile Drupal 8.9.x and Drupal 9.x go out
Comment #18
rajab natshahComment #19
rajab natshah