After enabled fb module I get this javascript error
Uncaught TypeError: Cannot read property 'js_sdk_url' of undefined
Drupal.behaviors.fb on fb.js:238
It breaks Linkit Ckeditor module.
Here pasted, the Chrome Inspector error, maybe it helps:

Uncaught TypeError: Cannot read property 'js_sdk_url' of undefined
Drupal.behaviors.fb fb.js:238
(anonymous function)drupal.js:41
D.extend.each:1
Drupal.attachBehaviorsdrupal.js:40
Drupal.theme.placeholderdrupal.js:271
D.fn.extend.ready:1
D.extend.ready.D.readyList:1
D.extend.each:1
D.extend.ready:1
CKEDITOR.plugins.add.init.editor.addCommand.exec/sites/all/modules/linkit/editors/ckeditor/plugin.js?t=A8LE4JO:23
a.command.exec/sites/all/libraries/ckeditor/ckeditor.js?B:20
e.extend.execCommand/sites/all/libraries/ckeditor/ckeditor.js?B:25
k.button.e.extend.click/sites/all/libraries/ckeditor/ckeditor.js?B:42
k.button.render.t.execute/sites/all/libraries/ckeditor/ckeditor.js?B:42
a.tools.addFunction/sites/all/libraries/ckeditor/ckeditor.js?B:10
a.tools.callFunction/sites/all/libraries/ckeditor/ckeditor.js?B:10
(anonymous function):2
onclick

Comments

Dave Cohen’s picture

try refreshing drupal's caches. If that doesn't fix it, add a watchdog call to fb_preprocess_page(), just to see if it is being called. I suspect it is not, but I can't say why not.

Anonymous’s picture

Thanks for your answer. I remove the fb folder and download everything again and cleared the cache, but the error still there: fb:238 Uncaught TypeError: Cannot read property 'js_sdk_url' of undefined.

Also there is another error message, I don't know if it's related:
FB.getLoginStatus() called before calling FB.init() at all.js:9

Regards

Dave Cohen’s picture

Title: Cannot read property 'js_sdk_url' of undefined » FB.getLoginStatus() called before calling FB.init()
Category: bug » support

Some other module is initializing the older facebook javascript, or initializing without an apikey.

Disable any other module which integrates with facebook as described on http://drupal.org/node/933994

Anonymous’s picture

Hi Dave,
I'm sorry for give you the run-around with the errors, after reset the cache and disabled Facebook social module the last error disappears, but the first ('js_sdk_url') still there.

Thank you

Dave Cohen’s picture

Title: FB.getLoginStatus() called before calling FB.init() » Cannot read property 'js_sdk_url' of undefined

Did you understand comment #1 where I suggested the watchdog message? Can you add that to determine whether fb_preprocess_page is being called at all?

Are you using an unusual theme? Can you try to reproduce in garland or marina theme?

Anonymous’s picture

Yes, I added a watchdog call, and fb_preprocess_page() is been called. I change the theme and the admin theme to Garland and the same error again. :(

Dave Cohen’s picture

Now its officially mysterious.

Do you have the know-how to step through javascript in say FireBug? I'd like know what Drupal.settings, and specifically Drupal.settings.fb is when that error happens.

Or view the source of the page and look for where Drupal.settings is set.

I'm assuming this is a problem on your end because no one else has reported it. But I'd like to understand what's going on.

Anonymous’s picture

Can I send you the url by contact form?

maddentim’s picture

I am having this issue as well in connection with the imce module. It makes a popup for rich text editors like tinymce. If I disable fb, then all works fine. When fb is enabled, the popup does not load all the elements needed. In firebug console, it shows an error with Drupal.settings.

Drupal.settings.fb is undefined
http://example.com/sites/all/modules/fb/fb.js?T
Line 238

In my testing I see that fb_init getting called when the pop loads, but fb_preprocess_page is not. As a workaround, I tried adding a module_invoke in imce for fb_preprocess_page, but got errors from it. "Missing argument 1 for fb_preprocess_page() in /.../sites/all/modules/fb/fb.module on line 231.". It's just not the way to call a preprocess i gather.

function imce() {
  module_invoke('admin_menu', 'suppress');//suppress admin_menu
+  module_invoke('fb', 'preprocess_page');//call fb
  $jsop = isset($_GET['jsop']) ? $_GET['jsop'] : NULL;
  print imce_page($GLOBALS['user'], $jsop);
  exit();
}

I need to figure this out as it has broken IMCE and it is how I add images for page content... I could move away from imce, but i would have to retrain the users... argh...

What controls when a module calls a preprocessor?

dtecson’s picture

I did a bad thing to fix this, but it works for now. The issue is happening here
if (typeof(FB) == 'undefined') {
// Include facebook's javascript. @TODO - determine locale dynamically.
//jQuery.getScript(Drupal.settings.fb.js_sdk_url);
jQuery.getScript('http://connect.facebook.net/en_US/all.js');
}

So just I connected directly to the needed js file for now.

maddentim’s picture

Hi, In the end, I hacked fb so that it ignored IMCE pages. Not the ideal workaround, but it duct taped this particular issue until a better solution is devised.

diff --git a/sites/all/modules/fb/fb.module b/sites/all/modules/fb/fb.module
index 68a5ad2..9ca20aa 100644
--- a/sites/all/modules/fb/fb.module
+++ b/sites/all/modules/fb/fb.module
@@ -217,11 +217,8 @@ function fb_init() {
     fb_js_settings('js_sdk_url', variable_get('fb_js_sdk', $default));
   }
 
-  // Add javascript to all pages except imce.
-  $page = $_GET['q'];
-  if ($page != 'imce') {
-    drupal_add_js(drupal_get_path('module', 'fb') . '/fb.js');
-  }
+  // Add javascript to all pages.
+  drupal_add_js(drupal_get_path('module', 'fb') . '/fb.js');
 }
 
 /**
mpdonadio’s picture

This is also happening with the LinkIt w/ TinyMCE. The Normal link, image, and HTML popups work fine, but they are self contained in TinyMCE and don't go through the bootstrap.

The LinkIt popup does go through the full bootstrap process. In this case, "fb_connect" is getting added to Drupal.settings, but "fb" isn't. Rootcandy is the admin theme, and edits use the admin theme.

fb, fb_app, fb_connect, fb_user, and fb_views are enabled.

EDIT: As far as I can tell fb_preprocess_page() is not being called. If it matters, the LinkIt page is wiredup with a hook_menu, but I don't know how TinyMCE launches this as a popup.

EDIT 2: If I browse directly to the URL that the hook_menu defines, fb_preprocess_page() doesn't get called either. The callback attached to the menu item just does a

print theme('linkit_dashboard', drupal_get_form('_linkit_form'));
exit;

so I suspect that is why fb_preprocess_page() never gets called.

EDIT 3: Tentative fix, but it just supressess the JS error and allows this particular popup to work.

diff C5w fb/fb-orig.js fb/fb.js
*** fb/fb-orig.js	Sat Nov 13 20:03:06 2010
--- fb/fb.js	Wed Dec 08 10:42:07 2010
***************
*** 225,234 ****
--- 225,236 ----
  
  
  
  
  Drupal.behaviors.fb = function(context) {
+   if (typeof(Drupal.settings.fb) == 'undefined') return;
+   
    // Respond to our jquery pseudo-events
    var events = jQuery(document).data('events');
    if (!events || !events.fb_session_change) {
      jQuery(document).bind('fb_session_change', FB_JS.sessionChangeHandler);
    }
Dave Cohen’s picture

mpdonadio’s picture

Thanks, I didn't run across that thread when searching for this problem. The patch worked for the LinkIt problem I described.

Dave Cohen’s picture

Version: 6.x-3.0-rc1 » 6.x-3.x-dev
Status: Active » Fixed

I've checked in that patch, so assuming this is fixed in latest dev. Please re-open if that is not the case.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.