Alanthar

  • Congratulations. :)
  • Posts: 22
Session writing
« 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

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Random Error Msg
« Reply #1, 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.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Session writing
« Reply #2, 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?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Session writing
« Reply #3, 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.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Session writing
« Reply #4, 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..?

Re: Session writing
« Reply #5, on November 9th, 2012, 10:30 PM »
Interesting. I've never encountered this before ever but I will keep an eye out for it.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Session writing
« Reply #6, 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.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Session writing
« Reply #7, 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.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Session writing
« Reply #8, 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.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Session writing
« Reply #9, on November 10th, 2012, 09:20 AM »
Hmm... Looks like I can't reproduce the error this morning. Fun.
Re: Session writing
« Reply #10, 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...

Re: Session writing
« Reply #11, on November 10th, 2012, 05:33 PM »
I've been doing some research on this issue... Is APC being used? What version?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Session writing
« Reply #12, 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.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Session writing
« Reply #13, 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.

Re: Session writing
« Reply #14, 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). ;)