Problem/Motivation
Some times a theme or module may attempt to add a JavaScript file that does not actually exist. When this happens, _locale_parse_js_file()
causes a PHP warning whenever the cache is cleared and it tries to parse the non-existing file.
In the following example the theme foo attempts to add the file bar.js.
Warning: file_get_contents(sites/all/themes/foo/bar.js): failed to open stream: No such file or directory in file_get_contents() (line 1488 of /var/www/drupal/includes/locale.inc).
This is of course not a common scenario, but it can be quite bothersome when working with themes and modules out of ones own control.
Proposed resolution
Adding a simple file_exists()
before file_get_contents()
in locale.inc's _locale_parse_js_file()
fixes the problem without any side effects. A patch containing this fix is attached.
Remaining tasks
Review patch and make sure I haven't missed anything.
User interface changes
None.
API changes
None.