Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: Alanthar on November 6th, 2012, 01:37 PM

Title: Session writing
Post by: Alanthar on November 6th, 2012, 01:37 PM
I'm getting a random error message here at wedge.org. Random meaning that this does not occur on every page load. There is seemingly no pattern to it.
Quote
Fatal error: Class 'wesql' not found in [~]/Sources/Load.php on line 2765
Title: Re: Random Error Msg
Post by: Arantor on November 6th, 2012, 01:44 PM
Interesting, since it shouldn't be possible... loadSession which replaces the session handler comes after loadDatabase which loads the main Class-DB.
Title: Session writing
Post by: Nao on November 9th, 2012, 08:25 AM
This is the first time I've noticed this bug, but it looks like it shows up from time to time... Eh, actually it's even showing up right now on my page...
Just look at the very bottom of the page.

Fatal error: Class 'wesql' not found in /Sources/Load.php on line 2765

Line 2765 = sessionWrite(), which is part of the functions called from the session handler initialized in loadSession().
I'm trying to understand why it can't find wesql here... It's initialized in loadDatabase(), which is loaded at the top of index.php... Strange innit?
Title: Re: Session writing
Post by: Arantor on November 9th, 2012, 04:03 PM
I've seen that once here and assumed it was related to you uploading some files, but it's only been the once...

Yup, I'm as confused as you are with the logic of it.
Title: Re: Session writing
Post by: Nao on November 9th, 2012, 05:17 PM
I see it all the time I look for it... I think it happens after some delay, when it has to recreate the session or whatever.
Thing is, even SMF 2.1 still has the same code. Maybe it's an issue on my server configuration...?

I guess we could test for wesql, and if not found, call loadDatabase() or at least do a getInstance() on it...?

:edit: I'm getting it on every page, actually... Maybe I can trace it then.
:edit: Nope... Third time was the charm :(
:edit: Seems to occur about 1 time out of 3 or 4... Maybe related to garbage collection or something..?
Title: Re: Session writing
Post by: Anthony` on November 9th, 2012, 10:30 PM
Interesting. I've never encountered this before ever but I will keep an eye out for it.
Title: Re: Session writing
Post by: Arantor on November 9th, 2012, 10:52 PM
Garbage collection shouldn't be that frequent. Not that it should make any difference.

Mind you, I also don't see why we shouldn't just move the loading and initial getInstance() calls from loadDatabase and stuff them directly in index.php and SSI.php...
Posted: November 9th, 2012, 10:38 PM

OK, so I'm seeing it too though not on local :/

Seriously, try moving the loading of Class-DB out of Load.php and into index.php and SSI.php, just in case it's something really banal like scoping.
Title: Re: Session writing
Post by: Nao on November 10th, 2012, 12:27 AM
Strangest thing ever...
Added this at the beginning of the function.

if (!class_exists('wesql'))
loadDatabase();

Guess what? Now the page crashes on loadDatabase's wesql::getInstance() call.... :-/

I'm not exactly sure what you mean by scoping in this case.
Also do note that it really happens only once in a while. On every single page the sessionWrite function is executed, and if I do echo class_exists('wesql'), it'll return 1... Except for the times when it returns false, and then the error message.
Title: Re: Session writing
Post by: Arantor on November 10th, 2012, 12:31 AM
PHP does occasionally have some weird issues where things are created in a local scope instead of globally where it should.

That said, I still say the loading of Class-DB should be bumped to index.php with the other core files.
Title: Re: Session writing
Post by: Nao on November 10th, 2012, 09:20 AM
Hmm... Looks like I can't reproduce the error this morning. Fun.
Title: Re: Session writing
Post by: Nao on November 10th, 2012, 04:12 PM
Nope... Didn't work a bit. Reproduced the bug, moved loadDatabase() to index.php, even manually added the wesql::getInstance() before loadDatabase(), and it STILL gave me the same error. And it's always caused by Load.php::sessionWrite(). It doesn't seem to remember the wesql class at all... Although it DOES remember $user_info and other globals. That's quite odd.

There may be a hint though: it looks like sometimes, the sessionWrite function is executed twice at the end of the flow... (?)
And it only generates the error on the second call.
But sometimes it's also only executed once, and then generates the error.
Posted: November 10th, 2012, 03:58 PM

Forget what I said, it's never executed twice...

So, I did a get_declared_classes() when $user_info['is_admin'] is on.

Normal execution:

 ...
    [103] => wetemItem
    [104] => wetem
    [105] => wesql
    [106] => westr_foundation
    [107] => westr_entity
    [108] => westr_mb
    [109] => westr

Failed execution:

...
    [103] => westr_entity
    [104] => westr_mb
    [105] => westr

So... It's interesting that both wetem and wesql are seen 'differently' and don't always remain in scope while westr is always seen.
Any clues, Pete...?

Also, very very oddly, it seems like IE9 NEVER shows me the error... (Which is why I thought it couldn't be reproduced.) Chrome does.
Posted: November 10th, 2012, 04:05 PM

Meh... I really don't see any differences between how westr and wesql are declared.
I've removed a couple of globals that are declared but never used in __construct and getInstance, but I don't think it's got anything to do with it eh...
Title: Re: Session writing
Post by: Anthony` on November 10th, 2012, 05:33 PM
I've been doing some research on this issue... Is APC being used? What version?
Title: Re: Session writing
Post by: Arantor on November 10th, 2012, 05:35 PM
Wait a minute, there's way more issues here. westr_foundation should be declared as well even in a failed state if westr is declared since westr extends (eventually) westr_foundation.

I don't understand why wesql still fails to be loaded in those cases.
Title: Re: Session writing
Post by: Nao on November 10th, 2012, 06:41 PM
- I don't think APC is installed or at least enabled. It doesn't show up in the phpinfo stuff.

- Hmm yeah, westr_foundation doesn't show up when the error happens, it's not that I forgot to paste it or anything. (The 102 first entries are regular PHP classes.)
Posted: November 10th, 2012, 06:03 PM

Could the main difference between westr_foundation and wesql/wetem be that it doesn't have a __construct() magic function..?
I don't know.

It's indeed quite odd that westr_foundation itself isn't registered, but its descendants are... :-/

Still, it's a server-related problem, I'm pretty sure. Must be somethin' with the PHP version... I don't know.
Title: Re: Session writing
Post by: MultiformeIngegno on November 11th, 2012, 01:25 AM
Nao, from Alwaysdata admin panel you can change the PHP version to run (check if still happens with other versions). ;)
Title: Re: Session writing
Post by: Nao on November 11th, 2012, 04:19 PM
I'm afraid I don't have access to their panel... I'm only a guest on shaitan's account.

Do you have this problem on your server btw?
Title: Re: Session writing
Post by: MultiformeIngegno on November 11th, 2012, 05:14 PM
Quote from Nao on November 11th, 2012, 04:19 PM
Do you have this problem on your server btw?
Me..? I couldn't install Wedge for the problem with the installer.. :P
Anyway I can see now that it works, did you change anything? :)
Title: Re: Session writing
Post by: MultiformeIngegno on November 12th, 2012, 06:56 PM
Nao..?
Title: Re: Session writing
Post by: Nao on November 12th, 2012, 11:37 PM
Nope, didn't do a thing.. You're talking about the session write error message at the bottom, right..?
Title: Re: Session writing
Post by: Arantor on November 12th, 2012, 11:42 PM
WTF is wrong with this? If Class-DB is loaded up front with everything, there is no reason for this to be broken.
Title: Re: Session writing
Post by: MultiformeIngegno on November 13th, 2012, 12:15 AM
Quote from Nao on November 12th, 2012, 11:37 PM
Nope, didn't do a thing.. You're talking about the session write error message at the bottom, right..?
Nope, I was talking about my server :P
Now I don't get the error anymore in the install.php page
Title: Re: Session writing
Post by: Nao on November 13th, 2012, 12:21 AM
I don't remember what your error was, Lorenzo... Sorry, the side-effects of my own personal burnout if you will.
So, if it's fixed, I don't have any reasons to connect to your FTP then..?

@Pete> No idea... Well, the error appeared in Chrome for me and never in IE, and currently I'm using Firefox and it doesn't exhibit this behavior. Do you still have it..?
Title: Re: Session writing
Post by: Arantor on November 13th, 2012, 12:21 AM
Yup, I have it in the footer still. But I see no reason why it should be any different in different browsers >_>
Title: Re: Session writing
Post by: Arantor on November 13th, 2012, 01:27 AM
/memerged in one of the other bug reports - it's the same bug. No sense in being untidy.
Title: Re: Session writing
Post by: Nao on November 13th, 2012, 08:14 AM
Quote from Arantor on November 13th, 2012, 12:21 AM
Yup, I have it in the footer still. But I see no reason why it should be any different in different browsers >_>
I assure you. I have yet to see the bug happen in IE. I'm also not sure about Firefox. I could only reproduce in Webkit...
Title: Re: Session writing
Post by: Arantor on November 13th, 2012, 02:49 PM
But not all the time either...
Title: Re: Session writing
Post by: MultiformeIngegno on November 13th, 2012, 06:33 PM
Quote from Nao on November 13th, 2012, 12:21 AM
I don't remember what your error was, Lorenzo... Sorry, the side-effects of my own personal burnout if you will.
So, if it's fixed, I don't have any reasons to connect to your FTP then..?
My problem was that in install.php I couldn't proceed with the installation because I got the error "Wedge Installer cannot find language files".
In these days I didn't touch anything but now I don't get that error anymore (I managed to install Wedge too)! Mistery
Title: Re: Session writing
Post by: Nao on November 21st, 2012, 02:20 PM
Quote from Arantor on November 13th, 2012, 02:49 PM
But not all the time either...
And it absolutely never, ever happened to me in either Firefox or Opera. (And IE as well I think...)

I don't see the reason behind WebKit being a problem when it comes to server-side session handling...!

I did a phpinfo both here and locally. The only differences between the two installs are: PHP 5.2.14 on wedge.org (5.3 locally), and session settings: wddx is added to 'registered serial handlers' locally. Also, 'use_only_cookies' is set to On locally, and Off on wedge.org.
Since ini_set() can change that, I don't really see much of a difference...

Even the PHP.net documentations wasn't helpful. I did read a lot of it...

I'm a bit torn between either returning false if !class_exists('wesql'), or instead using mysql_* functions directly to handle session saving... Uh.
Title: Re: Session writing
Post by: Arantor on November 21st, 2012, 03:08 PM
You can't really use mysql_ functions directly, because the connection won't be available to them anyway, as that resource is held inside wesql. That still doesn't explain how come half the classes that are loaded are not registered.
Title: Re: Session writing
Post by: Nao on November 21st, 2012, 03:31 PM
Quote from Arantor on November 21st, 2012, 03:08 PM
You can't really use mysql_ functions directly, because the connection won't be available to them anyway, as that resource is held inside wesql. That still doesn't explain how come half the classes that are loaded are not registered.
Well, it's very likely that it's a PHP or WebKit bug anyway... That is, something that's bound to be fixed in the future.
And because it doesn't hurt functionality, I think it's safe to just ignore the error for now.
Title: Re: Session writing
Post by: Arantor on November 27th, 2012, 11:18 PM
How could it be a Webkit bug? Seems to me it's something funny related to PHP doing unloading when it shouldn't.
Title: Re: Session writing
Post by: Nao on November 28th, 2012, 11:32 AM
I don't know... How could it NOT be a WebKit bug when it can only be reproduced on WebKit browsers...? I didn't say this arbitrarily. It just happens that I tested dozens of times on all browsers.

I didn't test, however, forcing a fake WebKit user agent on a non-WebKit browser, and the other way around...
Title: Re: Session writing
Post by: Arantor on November 28th, 2012, 05:13 PM
I'm not sure it is a Webkit bug as such but perhaps circumstances caused in the browser detection when it encountered a Webkit bug?