The core CKEditor plugins provide the getFile
returns without the leading slash, such as core/modules/ckeditor/js/plugins/drupallink/plugin.js
.
The point where this creates trouble is then in the core locale module:
Warning: file_get_contents(/libraries/panelbutton/plugin.js): failed to open stream: No such file or directory in _locale_parse_js_file() (Line 1145 in /srv/www/htdocs/MYPROJECT/html/core/modules/locale/locale.module).
This notice happens when displaying the CKEditor right after a cache rebuild, and is due to locale trying to find embedded t() strings.
The plugin works fine without the leading slash, but cause no further notices.
I don't know if this is due to a change in core or has always been this way, but the issue arises with multiple contrib CKEditor plugins (e.g. panelbutton, font and colorbutton)
Comment | File | Size | Author |
---|---|---|---|
#14 | 2756597.patch | 581 bytes | ilya.no |
Comments
Comment #2
kevinquillen CreditAttribution: kevinquillen at Velir commentedI had made those changes because there was another issue filed (#2718071: Use base_path() when referencing the plugin path.) that need to use base path to facilitate installations in subfolders.. is this not the way to resolve it? The difference being core does not integrate third party plugins in a way where they are in the root /libraries folder.
Comment #3
kevinquillen CreditAttribution: kevinquillen at Velir commentedThis plugin is also doing it:
http://cgit.drupalcode.org/ckeditor_a11ychecker/tree/src/Plugin/CKEditor...
Comment #4
ckaotikThe thing is, all addons providing CKEditor plugin that I've used in D8 (namely colorbutton, panelbutton and font) cause this notice. Core plugins provide their path relative to the drupal installation path, without a leading slash. Contrib plugins should do the same - yes,
base_path()
should most likely be used. It's just that I think we should remove the leading slash, so the path is relative to the Drupal installation instead of relative to the server root.The documentation on
base_path()
reads thatHow about using
ltrim(base_path(), '/')
instead?We currently aren't be able to use Drupal translation strings within the plugin.js (this is okay, the plugins aren't Drupal style JS anyways), however the JS system tries anyways and fails because its using plain php to read the file. This is where the notices are thrown.
Comment #5
ckaotikFor example, DrupalLink is a CKEditor plugin provided by core. Its implementation of getFile() is as follows:
Unlike
base_path()
,drupal_get_path()
does not return a leading slash. Therefore the core solution works nicely. It really is a shame thatdrupal_get_path()
does not work for the libraries folder :(Comment #6
kevinquillen CreditAttribution: kevinquillen at Velir commentedI considered the ltrim() route, but it feels like such a dirty hack. This might be an area that was overlooked in 8.x, or I am not seeing the function or method to do this cleanly. And yeah, since third party plugins and libraries go in /libraries, drupal_get_path() doesn't even see it. It's too bad drupal_get_path has no support for a 'library' option.
Comment #7
kevinquillen CreditAttribution: kevinquillen at Velir commentedI'll raise this issue in core because I have a feeling most CKEditor modules or other WYSIWYG based modules are going to have this same problem.
Comment #8
kevinquillen CreditAttribution: kevinquillen at Velir commented#2758579: Best way for getFile to retrieve file(s) from the /libraries directory?
Comment #9
kevinquillen CreditAttribution: kevinquillen at Velir commentedComment #11
kevinquillen CreditAttribution: kevinquillen at Velir commentedComment #13
kybermanHi @kevinquillen, I think we should reopen this issue, because exactly the same problem was introduced again by this commit: https://cgit.drupalcode.org/panelbutton/commit/?id=cae0b8f
This problem now exists also for colorbutton module.
Comment #14
ilya.no CreditAttribution: ilya.no as a volunteer and at Skilld for Skilld commentedAttaching patch for 1.1 version.
Comment #15
MikheevDesign CreditAttribution: MikheevDesign commentedI have the same problem: Warning: file_get_contents(/libraries/codesnippet/plugin.js): failed to open stream: No such file or directory в _locale_parse_js_file() (строка 1134
Comment #16
lukasss CreditAttribution: lukasss as a volunteer commented#14 needs to be fixed
Comment #17
ckaotikAs this issue is already marked as "Closed (fixed)", we'll have to open a new issue as a follow-up to this. Otherwise it's very unlikely this ticket will get any attention.
Comment #18
lukasss CreditAttribution: lukasss as a volunteer commentedCould you do that?
Comment #19
ckaotikFun fact: There are already three issues talking about this problem: this one, #2907730: Module can't find library and #2881820: Module can't find library in profile directory. Let's continue the discussion in the latter.