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.
By Anonymous (not verified) on
Sometimes, randomly, I get this very annoying error on all pages.
Warning: file_get_contents(xxxx.js) [function.file-get-contents]: failed to open stream: No such file or directory in _locale_parse_js_file() (line 1472 of xxxx\includes\locale.inc).
The 'xxxx.js' is a javascript file, located in a subfolder in my theme folder. When I disable the locale module, the error message disappears, so it's clear this is a problem with this module.
I am not familiar with module coding so I don't know how to start solving this problem.
Comments
locale.module
I found something that looks interesting in locale.module.
Line 833-895:
I think this is my problem. All my javascript is added by drupal_add_js()!
But, I'm no developer and I have NO insight in this.
Are you sure you have set the
Are you sure you have set the correct path when adding your javascript file? Because the system isn't finding the file at the location you've given. You may want to check permissions on the file as well.
Correct
Yes, the permissions are OK and I double-checked the file path wich is also correct.
But this couldn't be the problem because it does get the files (because no javascript file is broken) while the system keeps giving me these errors. Often when I refresh the window the error disappears. It appears randomly.
EDIT: when I completely remove the function mentioned in my first comment the error message is completely gone, with the locale module still working! So it's clearly this part that is causing the error. But I don't want to 'solve' it this dirty way because I don't know if this function is essential to the module (wich seems logical to me).
Change this:Open up
Change this:
Open up includes/locale.inc, and look for this code (the function _locale_parse_js_file)
Change it to the following:
Next time that happens, check that the filepath is actually the same as your javascript file. Change the code back to the original code when you are finished.
Thanks
Thanks for your time. Your reply made me look at the paths again. For some reason
base_path()
messed everything up.I used this:
And for some reason it did cause these errors. Now I use only
path_to_theme()
withoutbase_path()
and all errors are gone! Now my other problem is also solved.Thanks again.
In the documentation, it
In the documentation, it says:
You were adding the path WITH the base path, rather than relative to it. This meant that when Drupal was looking for the file, it wasn't finding it in the location you were telling it.