Re: RE: [PHP-GENERAL] Re: [PHP-DEV] Sessions and Objects
| From: | Stanislav Malyshev | Date: | Sun, 18 Jun 2000 08:07:41 +0000 |
| Subject: | Re: RE: [PHP-GENERAL] Re: [PHP-DEV] Sessions and Objects | ||
| References: | 1 | Groups: | php.dev php.general |
| Request: | Send a blank email to php-dev+get-21670@lists.php.net to get a copy of this message | ||
CT>> I hope the PHP team is aware that the object support in sessions is not
CT>> quite there and can keep improving the already excellent session library.
Sure object support *is* "quite there". But how do you imaging PHP to know
what class 'FooBar' means if you don't declare it? If you know some of
your apps using session can't know this class, do not put it in session.
What solution do you propose to this, how PHP is supposed to know what are
you meaning when you are saying 'this is object of class Foo'? It does
favor for you by not telling you "I don't know this class, go define it
and the return" but really giving you a mean to gracefully recover from
this problem or even ignore it. But do you really expect it to guess class
definition?
The bad part is that indeed stdClass is getting stored back and ruins
session data. But, if you opearate on session data without full knowledge
of the data, you could get worse things happen. Imagine having session
variable $foo and application loading session data, knowing nothing of
$foo, and then messing with it and storing it back. Bad. Nothing to do
with sessions too - your application should know your data.
The immediate solution for this would be just to have a bunch of stubs of
form:
class Foo {}
class Bar {}
class Baz {}
etc., etc. Thus you almost waste no time for those classes and still can
use sessions with unknown-to-you data. But then you can't work with this
data (which you couldn't anyway).
Do you have another proposals?
P.S. Could I please ask people to avoid expressions like "crap",
etc.? This really serves no puprose except irritating developers. If you
dislike PHP so much that you can't control your lanuage - OK, don't use
it, your health is more valuable. But why people on the list should
observe your swearing?
--
Stanislav Malyshev stas@zend.com
+972-3-6139665