We're using FB Connect and after logging in via Facebook, the redirect URL gets "?fbu=###" appended to it. This was causing so many issues with our caching layers that we had to disable it. I ended up commenting out:

vars.push('fbu=' + fbu);
(line 102 as of the 6.x-3.0-rc13 release)

... to avoid the problem.

Is this really necessary, i.e. do any of the FB modules actually use this GET param? If not, it would save quite a bit of grief to simply remove it entirely.

Thanks.

Comments

bleen’s picture

sub

Dave Cohen’s picture

It is intended to fix caching problems.

For example if your cached page shows a facebook connect button, but after the user connects you want to show their name and profile pic... well, you don't want the cached page. For most sites, being connected to facebook is like being logged into drupal, and caching is not desirable.

It's true that carefully built sites may still want caching on these pages. I'm open to configuration option that prevents the fbu from being appended, as long as the default is to append the fbu. I'll review any patches that do that.

breathingrock’s picture

Status: Active » Needs review
StatusFileSize
new3.47 KB

This patch adds an administrative checkbox to make the "fbu" parameter optional when calling FB_JS.reload().

Patch is from directory above the fb/ directory.

breathingrock’s picture

StatusFileSize
new2.82 KB

A better patch.

Dave Cohen’s picture

That patch is easier to read, for sure. I haven't looked it over in detail yet. I'm a little worried about the approach, as it removes the URL parameter but still reloads. In your case, the reload hits the cache, there's really no reason to do it. And also I'm not sure why, if the reload comes from the cache, you are not starting an infinite series of reloads. Because in the theory the page should also be served as if the user is not logged into facebook, and the javascript learns that the user is logged in, it should try to reload.

I agree there are cases where a full page reload is not necessary. Here's what I would recommend as a workaround. Create your own module, let's call it custom.module and have that module call drupal_add_js() to load custom.js. In custom.js define Drupal.behaviors.custom something like this...

Custom.sessionChangeHandler = function(context, status) {
  // Here, we can act when the user logs into or out of facebook.
};

Drupal.behaviors.custom = function(context) {
  jQuery(document).unbind('fb_session_change'); // Unbind the default behavior.
  jQuery(document).bind('fb_session_change', Custom.sessionChangeHandler); // Bind our custom behavior.
};

This will completely replace modules/fb handling of the session change with Custom.sessionChangeHandler(), which in the example above does nothing.

Dave Cohen’s picture

So, I recently learned that appending the user id to the url is a Bad Thing. I'm planning to get some change in the next release. Probably some combination of this patch and also change exactly what gets appended to the URL, maybe a hash of the id.

I wish I could remember exactly the problem I solved with this. Probably one of those situations where third-party cookies are disabled.

Dave Cohen’s picture

Version: 6.x-3.0-rc13 » 6.x-3.x-dev
StatusFileSize
new3.55 KB

Ok, here's the patch I'm planning to test on drupalforfacebook.org.

Instead of appending the user's ID, it will append a hash value.

Instead of enabled by default, it will be disabled. Its ugly, both the code and what it does to the URLs. So I hope eventually to get rid of this entirely. But there was a reason to add it in the first place so let's see whether anyone encounters problems without it.

Thanks again for your help with the original patch submission.

Dave Cohen’s picture

Status: Needs review » Fixed

I did check this in. Re-open if still an issue.

maciej lukianski’s picture

It seems to be working on my installation. I am releasing it on my users today due to #1225830: Email from Facebook, "Action Required for app" and will see what happens.

Anonymous’s picture

Updated both our dev and production servers today from 6.x-3.0-rc8 to 6.x-3.0-rc15, and am no longer seeing the "?_fb_js_fbu" parameter being appended to the URL.

The reason I upgraded was not an email from Facebook or caching but because there was an issue on our pages that used Facebook Connect. Users who were logged into Facebook and who had already connected to our app were temporarily seeing the message that non-connected users saw before the page refreshed with the correct Facebook information. Dave, I think you mentioned this is the correct behavior, but I think Facebook's servers are running slow, so this became more visible (never saw this before this week). I think it might also be related to the Facebook JavaScript OAuth 2.0 update (http://developers.facebook.com/blog/post/525/) that was released late last week. I watched the timeline on Chrome and noticed that the page was taking almost 3-4 seconds on Facebook's all.js before the upgrade.

Anyways updating to rc15 helped the issue. Dave, thanks so much for actively maintaining this module!

Status: Fixed » Closed (fixed)

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