diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 74b76ec..290f0ee 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -1141,6 +1141,11 @@ function _locale_parse_js_file($filepath) { throw new Exception('Only local files should be passed to _locale_parse_js_file().'); } + // Make sure the file actually exists. + if (!file_exists($filepath)) { + return; + } + // Load the JavaScript file. $file = file_get_contents($filepath); diff --git a/core/modules/locale/src/Tests/LocaleAddJSTest.php b/core/modules/locale/src/Tests/LocaleAddJSTest.php new file mode 100644 index 0000000..f82eaed --- /dev/null +++ b/core/modules/locale/src/Tests/LocaleAddJSTest.php @@ -0,0 +1,36 @@ +drupalGet(''); + } +} diff --git a/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.info.yml b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.info.yml new file mode 100644 index 0000000..2176fab --- /dev/null +++ b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.info.yml @@ -0,0 +1,9 @@ +name: 'Locale test add js' +type: module +description: 'Support module for adding javascript with the Interface Translation (locale) module enabled.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - locale +hidden: true diff --git a/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.libraries.yml b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.libraries.yml new file mode 100644 index 0000000..720bc93 --- /dev/null +++ b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.libraries.yml @@ -0,0 +1,4 @@ +drupal.locale_test_add_js: + version: VERSION + js: + non_existent_js_file.js: {} diff --git a/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.module b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.module new file mode 100644 index 0000000..29073d4 --- /dev/null +++ b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.module @@ -0,0 +1,15 @@ +