HAHAHAHAHAHAHAHAHAHA!
| From: | Szii | Date: | Wed, 14 Jun 2000 23:42:08 +0000 |
| Subject: | HAHAHAHAHAHAHAHAHAHA! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1889@lists.php.net to get a copy of this message | ||
Okay, now this really takes it...
To improve memory usage (I'm guessing), they imp'd a ref counting
scheme on objects. It's a good move...but the direct "=" operator
is a SET operator...or should be. It's NOT! It's a reference operator,
at least when dealing with classes!
HAHAHAHAHAHA!
Class1 = new class_Class1;
Class2 = new class_Class1;
Class2 = Class1; // REFERENCED!
This is PAINFULLY obvious after reg'ing a class with a session, changing
pages, and putting the following code in place...
$local_Mine = new class_Mine;
if (!session_is_registered("session_Mine"))
{
$session_Mine = new class_Mine;
session_register("session_Mine");
}
else
{
$local_Mine = $session_Mine;
}
This should ALWAYS be able to call $local_Mine->ANYTHING()! It's just
been new'd for this page...
Now, if you change pages, PHP saves $session_Mine via the server-side
cookie. Cool. You have a copy of it in $local_Mine, which is fine...you
can at least call methods off of $local_Mine.
But if you look at the "else" clause, $local_Mine = $session_Mine
and then call a method off of $local_Mine....well...guess what!
It's undefined! It's a reference to $session_Mine which has all of
the variable data but none of the methods! Note the lack of "&"
operators anywhere in that snippet.
I know I'm not the only one dealing with this CRAP (sessions+classes)
PHP team, can we rely on you for a design/implementation fix?
PLEASE?
We're DYIN' out here, and our projects are beginning to lag enough that
people upstairs are starting to ask questions. I dunno how much longer
I can say "It's a PHP thing" while I keep trying to hack different stuff
together just to make it WORK. I'm even getting the old "...and we're
using PHP instead of ASP because...?"
Am I doing something wrong?
HELP!
-Szii/Mike