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.
Hi there,
I have this notice on the site:
Notice: Undefined index: type in locale_js_alter() (line 911 of /modules/locale/locale.module).
Notice: Undefined index: type in locale_js_alter() (line 911 of /modules/locale/locale.module).
See the similar error (and solutions) in advagg module #2757527: Notice: Undefined index: type in advagg_js_alter()
Comment | File | Size | Author |
---|---|---|---|
#3 | add-condition-2758407-3.patch | 1.03 KB | kamalrajsahu21 |
Comments
Comment #2
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commentedComment #3
kamalrajsahu21 CreditAttribution: kamalrajsahu21 at Intelliswift commentedHere is the patch with condition added on locale_js_alter as well as in locale_css_alter.
Comment #4
hgoto CreditAttribution: hgoto as a volunteer commentedThank you for sharing the issue.
I think we need to identify the exact problem first. I guess that this notice message should be solved in a module which adds/alters the element in
$javascript
.@jasom, could you please add more information? It's necessary for other people to know the exact steps to reproduce the state. Thank you.
Comment #5
jasom CreditAttribution: jasom commentedAfter patch in #3 notice dissapeared.
@hgoto
Sure, which "more info" do you need?
See also this: #2760909: Undefined index: scope in drupal_get_js() (line 4372 of /includes/common.inc
Comment #6
hgoto CreditAttribution: hgoto as a volunteer commented@jasom, thank you for the comment.
I see. Yes, surely the notice may disappear with the patch #3 (I haven't tested it) but it doesn't fix the root problem, I believe. What do you think?
As you may know,
locale_js_alter()
is a hook implementation forhook_js_alter()
and such implementations expect the parameter$javascript
to be index array. And each element of the array can havetype
index.https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...
My question is that, "Can this notice message be reproduced with a new Drupal site without any condition? Or is there any condition?". You filed this issue as a bug not a support request and I thought other people need to know more information to address this issue. What you provided is the phenomenon. "Error message appears." It's not enough for other people to share the state you encountered, I believe. At least, steps to reproduce is needed, I think. In my experience, I haven't met this notice message with a new Drupal site and I'd like more information.
The following page may be useful. Please take a look.
- https://www.drupal.org/issue-summaries
Comment #7
yust22 CreditAttribution: yust22 commentedHello
I had a similar problem , which appeared when I modified a .js with hook_js_alter
function hook_js_alter(&$javascript){
$javascript['your_path/file.js']['data'] = drupal_get_path('module', 'module_name') . '/js/module_name.js';
}
I solved by adding the type and scope of javascript:
$javascript['your_path/file.js']['scope'] = 'header';
$javascript['your_path/file.js']['type'] = 'file';
I hope you find it useful
Comment #8
dunot CreditAttribution: dunot at Zina Design commentedIt's after installation of advagg 7.x-2.33.
Related issue
#3 removes the notice, kamalrajsahu21, thank you.
Comment #9
tanmaykAgreed with @hgoto. The
type
must be present there. So instead of fixing in the core, we should fix in related module. Above patch will remove the notice but the js added by module won't be processed inlocale_js_alter()
.Comment #10
edurenye CreditAttribution: edurenye as a volunteer commented'type' is not mandatory and should default to 'file' according to the documentation: https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_...
But Drupal never sets it to file, just always assume empty is file, so either we assume here that if type is not set, it should be file, or we change drupal_add_js to set it to file if empty.
For both solutions that patch is wrong.