Notice: Undefined index: scope in drupal_get_js() (line 4399 of /var/www/html/outsideonline/docroot/includes/common.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markdorison created an issue. See original summary.

mikeytown2’s picture

This is an issue with some 3rd party code that you're using. drupal_add_js() runs everything through drupal_js_defaults() which sets the scope. I'd look at all your hook_js_alter()'s. If you turn off AdvAgg you'd still have this issue most likely.

mikeytown2’s picture

You can see what alters are being ran by going to
admin/config/development/performance/advagg/info
and under AdvAgg CSS/JS hooks implemented by modules, at the bottom is js_alter

mikeytown2’s picture

Category: Bug report » Support request
mikeytown2’s picture

Status: Active » Postponed (maintainer needs more info)

Need more info in order to proceed.

mikeytown2’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Can not reproduce this bug as stated. Reopen if you have more info on how to reproduce this issue.

Summit’s picture

Status: Closed (cannot reproduce) » Active

Hi,

I have the same bug with update.php on latest .dev version with latest drupal 7

Notice: Undefined index: scope in drupal_get_js() (line 4472 of /includes/common.inc)

I can do this of course, but as said there, this is not the root cause.

greetings, Martijn

Summit’s picture

Hi,

I have the same bug with update.php on latest .dev version with latest drupal 7

Notice: Undefined index: scope in drupal_get_js() (line 4472 of /includes/common.inc)

I can do this https://www.drupal.org/project/drupal/issues/2760909 of course, but as said there, this is not the root cause.

greetings, Martijn

mikeytown2’s picture

What alters are running? See #3

Summit’s picture

Hi,
I see:

js_alter: 4
  advagg
  logintoboggan
  eu_cookie_compliance
  _advagg_locale

greetings, Martijn

mikeytown2’s picture

Status: Active » Needs review
FileSize
6.3 KB

This patch will log the missing scope. Clear all caches (system wide) after applying.

patch looks like the this ignoring white space

diff --git a/advagg.module b/advagg.module
index 91f93a3..580d032 100644
--- a/advagg.module
+++ b/advagg.module
@@ -630,10 +630,13 @@ function advagg_module_implements_alter(&$implementations, $hook) {
     $implementations['advagg'] = $item;
   }

-  // Replace locale_js_alter with _advagg_locale_js_alter.
-  if ($hook === 'js_alter' && array_key_exists('locale', $implementations)) {
+  // Replace locale_js_alter with _advagg_last_js_alter.
+  if ($hook === 'js_alter') {
+    if (array_key_exists('locale', $implementations)) {
       unset($implementations['locale']);
-    $implementations['_advagg_locale'] = FALSE;
+    }
+    // Add to bottom so it runs last.
+    $implementations['_advagg_last'] = FALSE;
   }

   // Move advagg_file_url_alter to the bottom.
@@ -689,7 +692,8 @@ function advagg_module_implements_alter(&$implementations, $hook) {
  *
  * This is a locking wrapper for locale_js_alter().
  */
-function _advagg_locale_js_alter(&$js) {
+function _advagg_last_js_alter(&$js) {
+  if (function_exists('locale_js_alter')) {
     // If the variable is empty then get the latest variable from the database.
     $name = 'javascript_parsed';
     $parsed = variable_get($name, array());
@@ -764,6 +768,14 @@ function _advagg_locale_js_alter(&$js) {
     lock_release('locale_js_alter');
   }

+  // Log missing scope, so the JS can be fixed.
+  foreach ($js as $key => $item) {
+    if (empty($item['scope'])) {
+      watchdog('advagg', 'Missing scope. Key: %key <br>Item:<pre>@item</pre>', array('%key' => $key, '@item' => print_r($item, TRUE)), WATCHDOG_DEBUG);
+    }
+  }
+}
+
 /**
  * Implements hook_system_info_alter().
  */