Problem occurs in both 5.1-1.1 and 5.1-1.x-dev. Most of the time everything is fine, but occasionally when you logout, you get a blank screen in Firefox and the following two messages in the Apache error log on the server:
[Sun Feb 03 17:39:43 2008] [error] [client 122.57.xxx.xxx] PHP Notice: Trying to get property of non-object in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\test\\modules\\securesite\\securesite.module on line 291, referer: http://www.xxx.xxx
[Sun Feb 03 17:39:43 2008] [error] [client 122.57.xxx.xxx] PHP Fatal error: Call to undefined function theme() in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\test\\modules\\securesite\\securesite.inc on line 8, referer: http://www.xxx.xxx
Refreshing the page doesn't help, but entering a new URL kicks it off again. Caching is set to normal.
Thanks and regards,
Peter.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | contrib-5.securesite.php-error2.junyor.patch | 876 bytes | junyor |
| #8 | contrib-5.securesite.php-error.junyor.patch | 3.49 KB | junyor |
| #2 | Drupal Modules 080204.zip | 65.57 KB | wotstheguts |
Comments
Comment #1
junyor commentedWhat revisions are you using of securesite.module and securesite.inc? Just look at the top of the files for the ID line.
The notice isn't really a problem. It's the error that's causing the blank screen. This should only happen if there's a problem initializing some parts of core before securesite_init(). What version of Drupal are you using and what other contrib modules do you have installed?
Comment #2
wotstheguts commentedHi,
Using the ones from 5.x-1.x-dev:
$Id: securesite.inc,v 1.10.2.4 2008/01/31 20:19:32 darrenoh Exp $
Using Drupal 5.7. The attached Word document lists the modules.
I tried turned the caching off completely (it was set to normal, the default) in Drupal and the error hasn't occurred at all today. Tomorrow I will switch the caching back to normal and see if the problem occurs again.
Thanks,
Peter.
Comment #3
wotstheguts commentedOK, I've confirmed now that it's the caching. It worked perfectly for a day and a half with caching turned off completely. An hour after I switched it on (normal caching, not aggressive) I got the problem with the blank screen again.
The exact process I went through this morning was:
1. Login with admin account, turn on caching, then logout.
2. Login through the securesite page with guest access.
3. Left the PC idle for about an hour.
4. Login again as admin.
5. Logout - blank page.
It seems to remain flaky after this happens until I restart Apache.
Hope this gives you enough information to replicate the problem. The module is perfect for what I want to do aside from this glitch. I don't want to leave caching off, as it really helps when the server is heavily used.
Thanks and regards,
Peter.
Comment #4
NaX commentedHave a look at this issue; the suggested code was committed so I don’t know how much this helps.
http://drupal.org/node/119009
Your second error suggest you need to add something similar as the above URL but to the securesite_user_auth() and it would have to be for DRUPAL_BOOTSTRAP_FULL.
Something like
Comment #5
wotstheguts commentedHi, thanks very much for your suggestion, it seems to make sense but when I tried it, it prevents users from logging in at all - it just takes them back to the initial login screen.
Cheers,
Peter.
Comment #6
junyor commentedI think if you call DRUPAL_BOOTSTRAP_FULL, it'll fire hook_init, which'll start securesite authentication again.
Comment #7
junyor commentedOK, I reproduce this using the instructions wotstheguts provided. I either get errors on t() or theme(). During a cached bootstrap, drupal_bootstrap calls drupal_bootstrap with DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, which calls _drupal_cache_init. _drupal_cache_init then fires hook_init. Since securesite_init() uses functions from common.inc (t()) and theme.inc (theme()) and neither has been included by _drupal_cache_init(), errors occur. We could either make our own t() and/or theme() alternatives or include common.inc and/or theme.inc at the top of securesite_init().
I'll work on a patch that includes common.inc to see what y'all think. Cached bootstrapping will be a bit slower, but at least it'll work. ;)
Comment #8
junyor commentedPlease test the attached patch. Make sure you update to the latest DRUPAL-5 branch code first, as I've committed some changes today that will cause patching to fail otherwise.
Comment #9
NaX commentedI have not tested your patch but I had a look at it.
Your securesite_status_messages() function looks good but I don’t think including common.inc will work as the t() function in common.inc has a theme() function call in it.
Nowhere are we using argument replacement so in theory we should not have to worry about that theme('placeholder', $value) call.
When somebody is running caching they are trying to speed up its site performance and I think including common.inc every time hook_init() is called would be counter productive.
I think a better solution would be to create our own t() function that way the only extra code is one function rather than a +2000 line file.
Here is my idea for a t() function.
Comment #10
junyor commentedt() is only part of the problem. The theme('status_message') calls in securesite.inc are also part of the problem, which is why I replaced them.
I wonder why the patch worked if t() still calls theme()? Maybe by the time it's called, theme() is defined?
I'm wondering if we're not barking up the wrong tree. This problem seems to be related to guest logins. I use caching on several sites that use securesite and I've never run into this problem.
One thing I noticed is that we don't call module_invoke_all('exit') in securesite_goto(). Could that be related?
Maybe there's something wrong with the way we create the anonymous user session for guests?
Comment #11
junyor commentedHere's an alternative fix. The basic problem is that the cache table contains a cached page from when the guest was logged in, but that cached information doesn't contain the dialog code used during authentication. When we try to login after a guest, the cached data is used and the PHP error occurs. NaX almost had the correct solution, but data would still be pulled form the cache. So, we have to clear the cache, then run a full bootstrap.
Here's an easy way to reproduce the PHP error. You must have guest logins enabled for this to work:
1) Login as a guest
2) Delete the session cookie stored for the server
3) Restart your browser to clear the HTTP Auth cache
4) Visit the site again
At this point, you should get the PHP error. To get rid of the PHP error, empty the cache_page table in your database.
Comment #12
junyor commented@wotstheguts: I'd appreciate it if you could test the patch in #11 on your site to see if it resolves the problem. if so, I'll commit it to the DRUPAL-5 branch.
Comment #13
wotstheguts commentedThanks very much junyor, I'll give it a go and get back to you ASAP.
Comment #14
wotstheguts commentedAll looks good, applied the patch and switched the cache back on, and have been using it all day with no problems whatsoever. Awesome, thanks heaps for your help!!!
Cheers,
Peter.
Comment #15
junyor commentedFixed on the DRUPAL-5 branch.
Comment #16
darren ohComment #17
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.