Closed (fixed)
Project:
Drupal for Facebook
Version:
6.x-3.x-dev
Component:
Page Tabs (iframe)
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Oct 2011 at 02:08 UTC
Updated:
22 Jun 2012 at 18:21 UTC
Jump to comment: Most recent file
Comments
Comment #2
Dave Cohen commentedIf that doesn't work, its probably because some module is initializing the theme too soon. Sometimes error messages cause this, so look in your drupal log for any errors or warnings.
Try putting dpm() or breakpoint in init_theme(). To see when it is first called and why. Something like
dpm(debug_backtrace());should tell you.Comment #3
frank0051 commentedOkay, I put dpm(debug_backtrace()); in the init_theme() function in includes/themes.inc but it gave me a PHP error that DPM was an undefined function. Thoughts?
Also, no errors or warnings in the log when loading the Facebook app.
Comment #4
frank0051 commentedNevermind, realized I had to install Drupal devel module. So, I have three arrays (the first has 11 elements, the second 13 elements, and the third is 18 elements), what do I need to look for? Each of them say they were called from /home/crooms/public_html/includes/theme.inc, line 44 before I expand them out.
Comment #5
Dave Cohen commentedFirst of all, enable fb_devel.module. Reproduce the error and look for any messages on the page or in the drupal logs. The README.txt has basic instructions for troubleshooting.
From that dpm() output, you need to expand the stack trace to figure out what is calling theme().
Comment #6
frank0051 commentedYes, I already did install devel (look at post #4) and I have the arrays outputting. As far as arrays: I only have one, apparently I executed an admin action at the same time, so the last time I looked it shot out three.
Now, inside of the array, the 2nd element in the stack is this:
"1 (Array, 4 elements)
file (String, 44 characters ) /home/crooms/public_html/includes/common.inc
line (Integer) 2986
function (String, 5 characters ) theme | (Callback) theme();
args (Array, 2 elements)"
So, what do I need to look for now, what's the next step to fixing this? Again, there is no error getting generated in the Drupal log, it is just that the theme settings don't work for the Facebook custom tab :-(.
Comment #8
Dave Cohen commentedSince you did not have devel.module installed until comment #4, I'm assuming you don't have fb_devel.module enabled. Enable it.
You need to figure out the first argument being passed to theme(). And you might need to inspect further up the call stack to see exactly what it making the first call to theme().
Comment #9
frank0051 commentedOkay, I have fb_devel.module enabled. From there, it told me to add the stuff in the readme to the settings.php file, and I did. However, that causes a somewhat annoying problem: a new session each time I go to the Facebook tab. And, if I log into the site through the iframe on Facebook (which I have to do to read the stack), it sends me to a page that doesn't exist and I get a 404 error. Doesn't happen when I do it on the regular site.
In any case, I temporarily enabled devel permissions for anon. users so I wouldn't have to log in and here is the expanded arguments for the first array with mentioned theme():
The only other array listed before that is array 0 and that is the one that calls init_theme():
Comment #10
Dave Cohen commentedMake sure you've read everything in the readme.txt, and the documentation that it refers you to. Pay close attention to anything that fb_devel.module has to tell you. Its often a good idea to enable devel info for anonymous, when troubleshooting these sorts of things.
You can see what modules/fb thinks is going on by enabling the block it provides. It spews out a lot of info. At the very least get to the point where it knows the type of page is a tab. If it knows the type of page, and still has the wrong theme, you'll have to figure out what is causing init_theme() to be called.
Comment #11
frank0051 commentedI believe I have done everything needed according to the Readme, but even with the blocks enabled it doesn't write any errors to the log. The Facebook debug tool doesn't give any errors that need to be fixed either. The only thing the status says is "Not a canvas page".
Within the fb_settings() array it notes that it is a page tab
So unless the page is supposed to specially equal to "page status=tab" then I don't really know what else to do. I'm trying to follow along with everything you are saying and everything that is in the read-me, but I'm still getting nowhere.
Comment #12
frank0051 commentedI've disabled basically everything besides Drupal Core and optional core stuff, Ubercart, CCK, and Views and I'm still not making any progress. I'm going to put a fresh install on a subfolder and see if I get any progress but I'm beginning to think this isn't an isolated incident.
Comment #13
frank0051 commentedWell, I have a brand new install at http://www.croomsalumni.com/test and the only modules on it are devel and Drupal for Facebook. The custom app is at http://www.facebook.com/apps/application.php?id=233959169994957
I have SSL on the page, I have the FB library installed exactly where you tell us to in the readme, I have the settings.php file set up correctly, and I still cannot get the theme to set for the tab. There are only two possible explanations: 1) I'm still not setting it up properly (I'm putting that at a 10% chance) or something is not functioning correctly in the module, perhaps because of the recent Facebook upgrades.
Do you have any suggestions? I can provide you an admin account on Drupal and you are welcome to add the custom app to any of your pages to try out. I'm just not making any progress on this end. :tear:.
Comment #14
Dave Cohen commentedTry adding debug output in fb_tab.module. Look for the FB_OP_INITIALIZE clause of fb_tab_fb(), add something like:
If global theme or custom_theme is already set, it will not attempt to change it.
Comment #15
frank0051 commentedOkay, well it is running fb_tab_fb() function, but the $op variable is never equal to FB_OP_INITIALIZE. The first time the fb_tab_fb() function is called, the $op variable is equal to FB_OP_CURRENT_APP and it runs the elseif ($op == FB_OP_CURRENT_APP && fb_is_tab()) section of the code. The second time fb_tab_fb() is called, the $op variable is equal to "post init" but as far as I can tell that isn't an elseif switch option so nothing happens. The third time fb_tab_fb() is called, the $op variable is equal to "fb_op_js", but again, it doesn't appear that that is a switch option. Maybe I'm missing some stuff, but basically what I did was add an echo $op; right after the fb_tab_fb() function is created because when I first added the code you suggested nothing happened, so I figured it wasn't even getting that far.
Comment #16
Dave Cohen commentedWhen $op == FB_OP_CURRENT_APP, fb_tab.module should return the $fb_app data structure. (Basically, fb.module is asking "which app is currently active?" and fb_tab.module is saying, "this is a page tab, and therefore I know which app it is."). Can you tell whether it is returning an $fb_app?
If fb.module should then initialize the facebook php sdk, it will call FB_OP_INITIALIZE. Since it is not calling that app, either it is failing to initialize, or no $fb_app was returned.
The other ops don't matter in this case.
Comment #17
frank0051 commentedNo, it doesn't look like it is echoing out any data when I try to get the $fb_app to echo. So what do you think is not occurring within that function?
Comment #19
Würden commentedI've been ripping out my hair for over a week now with the exact same problem, and a few other people seem also to have the problem when looking in the issue queue - maybe there is a problem with the module? the theme is never initialized. Here is a similar issue: http://drupal.org/node/1197116
if i do a dpm for $fb_app in the end of the fb_tab_fb function it returns all the informations from the app currently used, in the variable I can see that fb_app_data->fb_tab->custom_theme is indeed set to the custom theme it should be, so it looks like this is not the problem.
I should add that I have the problem in Drupal 7, but it might as well be the same.
_fb_tab_get_config also returns an array with the correct custom theme only used for tabs, so I'm pretty lost.
I can also add that the same theme works perfectly when set for canvas pages.
Comment #20
Würden commentedI found a fix for the Drupal 7 branch, see: http://drupal.org/node/1197116
Comment #21
frank0051 commentedSo Dave, what do you think.
Comment #22
Dave Cohen commentedSounds like the 7.x version is sorely in need of that fix.
This issue is the 6.x version, right?
Comment #23
frank0051 commentedYes, Drupal 6 issue. But would the same thing apply? If not, what do you think is happening with the information I provided? Why do you think $fb_app isn't being set?
Comment #24
frank0051 commentedShould I take the silence over the last two weeks as we don't know what's going on?
Comment #25
Dave Cohen commentedTrue enough that I don't know what's going wrong. Also was away all of last week.
Are you including fb_settings.inc in your settings.php?
Comment #26
frank0051 commentedYup:
include "sites/all/modules/fb/fb_settings.inc";
Comment #27
Dave Cohen commentedtry
and paste what you see here.
On the facebook "advanced" settings, do you have it using oauth2 signed requests?
Comment #28
frank0051 commentedCannot do that because it causes PHP parsing errors because other headers are being sent. Where else can I put it?
Comment #30
Dave Cohen commentedTry...
It wont render the page, but should show you the data.
Also, try the .dev build instead of the 3.1. There may be a fix in fb_settings.inc to parse the signed requests.
Comment #31
frank0051 commentedI've had the dev for a while, just updated to the recent one (mine was about two-three weeks old). Still not working even on my clean install.
It outputs this:
Array
(
[fb_page] => 228511730536994
[page_id] => 228511730536994
[type] => page_tab
[cookie_domain] => page_tab
)
Comment #32
frank0051 commentedActually, not it is even worse. The view path is node/1 but the profile_tab_url is now set to http://www.croomsalumni.com/test/fb_cb/233959169994957/fb_tab/view, which is just a blank page.
Comment #33
Dave Cohen commentedSo it looks like fb_settings.inc is determining that it is a page tab.
The profile_tab_url looks fine. That's how it now works. When you get a blank page, check your error logs. Make sure PHP is configured to show all errors including startup errors.
Go back to #16, are you sure even with the updated modules/fb that fb_tab.module is not returning an $fb_app?
Comment #34
frank0051 commentedWell, I think I have the logging set correctly, but the only thing I'm getting is:
Back on 16, it still isn't hitting FB_OP_INITIALIZE
function fb_tab_fb is called five times with the following arguments for $op:
get_app
current_app
get_app
init
post init
exit
Comment #35
Dave Cohen commentedFB_OP_INITIALIZE is a constant. FB_OP_INITIALIZE and 'init' are the same thing.
Is the theme you're trying to use enabled?
Comment #36
frank0051 commentedyes the theme is enabled.
I've put some more echos in there, and elseif ($op == FB_OP_INITIALIZE) { is evaluating as true, so it does go into that portion of the function.
$GLOBALS['custom_theme'] is getting set to facebook as well (that's the name of my theme). $use_ob is set to 1 (which I guess is true). The site isn't offline so the dummy theme isn't getting set. $GLOBALS['fb_tab_post_process'] is set to 1 (true). It doesn't run if ($_REQUEST['q'] == FB_TAB_PATH_VIEW) - so, that seems to be where the FB_OP_INITIALIZE fails. The $_REQUEST['q'] is set to fb_cb/123354554434979/fb_tab/view while the FB_TAB_PATH_VIEW is set to fb_tab/view, so it evaluates false and there is nothing else in the FB_OP_INITALIZE portion of the if-then statement to run.
Comment #37
Dave Cohen commentedDuring that ($op == FB_OP_INITIALIZE), what is $GLOBAL['theme'] and what is $GLOBAL['custom_theme']?
When init_theme() first runs, what is the value of $GLOBAL['custom_theme']?
Comment #38
frank0051 commentedRemember, it's GLOBALS not GLOBAL. $GLOBALS['theme'] isn't set and what is $GLOBALS['custom_theme'] is set to facebook after it hits the if (!isset($GLOBALS['custom_theme'])) .
Where is the init_theme function, I don't see it in the fb_tab.module file (declared or called)...
Comment #39
Dave Cohen commentedinit_theme is somewhere in drupal core, maybe includes/theme.inc. I'm not sure.
Find it a determine whether i$GLOBALS['custom_theme'] is set to something else when it is called.
Comment #40
frank0051 commentedWell how do you suggest I find that out, I'm not a developer here...it this something the dev module could tell me?`
Comment #41
Dave Cohen commentedWe're back to where we were in comment #2.
Put something like
At the top of the init_theme function.
Comment #42
frank0051 commentedInterest, Init_theme() isn't even being called on the facebook tab, my echo isn't be pushed out on the tab page. In the regular site, the custom theme is null in the echo.
I checked what the source look like for http://www.croomsalumni.com/fb_cb/123354554434979/fb_tab/view and it is just this:
So, in essence, something in the module is stopping the rest of the Drupal processes from continuing on.
Comment #44
frank0051 commentedJust upgraded to the Nov. 29th dev release; cannot say there is any difference - still blank.
Comment #45
wisniewski commentedI have the same problem, Drupal stops and display blank page.
Comment #46
wisniewski commentedTricky workaround: using Domain Access create a subdomain for www, fb app and fb tab. Than the rest of configuration is inside Facebook. Poor but works. Good to have SSL certificate with wildcard.
Comment #47
frank0051 commentedSadly, I don't have a wildcard SSL certificate
Comment #48
Dave Cohen commentedUsually when drupal displays a white screen there is an error somewhere, i.e. an apache log. If PHP is configured correctly it will display the error somewhere.
Comment #49
frank0051 commentedIt's not a white screen though in the sense of an error, it's a white screen in that PHP hasn't pass along anything to render. The scripts are running fine, for some reason your module isn't calling back to the core to render the theme and continue with the rest of the process.
I mean, we know this isn't limited to my installation. We have another person. And, I've set up a clean install to test it on too. How can you explain that? So, we definitely know it is something related to how your module is interacting with something else. May that be an actual error in your module or a server setting on your end that is unconventional to how others have it set up.
Comment #50
frank0051 commentedDave, it's been suggested I offer payment for services. If you can get this problem solved by New Years, I'll provide you $30. That seems like a fair offer since a) this is a major feature of your module and b) I'm no longer the only person experience this problem (so it shouldn't be my sole responsibility to finance this thing, haha).
Comment #51
frank005 commentedJust upgraded to the Dec. 12th dev, cannot say it made a difference. I think infotrendy had it right: this is a bug report since multiple suers are having the problem. I've also checked the Apache error logs, nothing there. It's not a parsing error, otherwise Php would display an error. I think you need to go back to comment #42 and look how I mention that init_theme isn't called in the module. Since its not there, where is it called? I don't know Drupal, but I think that is the starting point. We can also show that it isn't an PHP error because I can echo stuff from inside the functions in fb_tab.module in order to not make it a blank page.
I can tell you exactly what's happen too:
function fb_tab_fb is called six times:
The first time it doesn't evaluate to any of the if_elseif statements so it ends.
The second time, it evaluates to true for the FB_OP_CURRENT_APP && fb_is_tab, so it steps through that.
The third time it doesn't evaluate so it doesn't run.
The fourth time it runs the FB_OP_INITIALIZE and it hits the fb_is_tab() statement right after that and evaluates to true. IT then sets $GLOBALS['custom_theme'] equal to facebook. It then sets $use_ob to true. It doesn't look like it sets $dummy equal to anything. Then, it runs the if ($use_ob) { statement. After that it hits the if ($_REQUEST['q'] == FB_TAB_PATH_VIEW), but it evaluates to false - so nothing associated with that statement runs. And, finally, the if ($path && $path != FB_TAB_PATH_VIEW) { evaluates to false as well, so it doesnt run either. It's officially out of stuff to run with that FB_OP_INITIALIZE
The fifth time it hits fb_op_post_init.
The sixth time it finally hits FB_OP_EXIT && fb_is_tab()) . It evaluates to true on if (isset($GLOBALS['fb_tab_post_process']) && $GLOBALS['fb_tab_post_process']) { . However, somehow it gets stuck on this $output = ob_get_contents();
and any echo statements added after that don't display.
So, what happens there - is that normal? what is ob_get_contents() supposed to do? If it stops the rest of the function from running when it otherwise should, we now know where the issue lies. Or, is it perhaps echoing stuff before the ob_get_contents() is called is messing up the function? Or perhaps the output buffer isn't set properly in the previous functions? Is there another way to go around using the ob buffer?
Comment #52
frank005 commentedalso, another interesting question I have is should I be able to echo stuff when the ob_start() has been called?
Comment #53
wisniewski commentedIf I can somehow confirm the case, let me know, but results seams to be the same.
During general tests of FB Tabs I figure out on one forum (that I can not find now), that this thing happens on polish hosting - home.pl (my case), and the solution was to change the extension of the file to .php (.html didn't work). That test was outside of Drupal.
Comment #54
Dave Cohen commentedPlease try this patch. It renames a couple functions, for clarity. But the important change is to not rely on $_REQUEST['q'] to determine the path.
Comment #55
frank005 commentedThis works, you need to commit this ASAP and dump out a new version of this as a critical release, haha.
That being said, it opens up a new can of worms: the handling of links within the iframe isn't uniform: sometimes they will open in the iframe, sometimes it will trigger a new canvas, and sometimes it will open in the main browser window. When it does open in the iframe, sometimes it will carry over the Facebook theme, sometimes it won't. It does seems, however to be dependent on the type of page that you are linking to: for instance, my links that go to custom pages/panel pages are the ones that don't carry the theme over.
At this point, I just enabled processing on iframe tabs and disabled Links send user to canvas pages so it just pops up with the link directing to the main website and its theme.
Comment #56
Dave Cohen commentedThere's a checkbox on admin/build/fb/fb_tab to control whether links go to canvas pages. If the link is generated by l() or url() functions, this should work. If the link is generated some other way, there's not much modules/fb can do about it.
I'll mark this issue fixed when the patch is pushed to git. Any further discussion of the links should be moved to its own thread.
Comment #57
Dave Cohen commentedThis was actually committed some time ago. Never updated issue status.