#27659 [Com]: Cannot re-assign $this

2004-09-22 Thread thejam at gmail dot com
 ID:   27659
 Comment by:   thejam at gmail dot com
 Reported By:  js at enradia dot com
 Status:   Bogus
 Bug Type: Unknown/Other Function
 Operating System: linux 2.6.3
 PHP Version:  5.0.0RC1
 New Comment:

How Silly.  We used $this for just about every result set in a db
query.  We have like a hundred applications.  I just ran a sript on our
whole htdocs directory and changed them all to $result.  Works fine.


Previous Comments:


[2004-08-23 20:10:48] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

As helly posted originally, this is expected behavior.  
One of the changes between php4 and php5 is that objects 
types are no longer mutable.  You can not change $this 
in php 5, by design.



[2004-08-23 20:01:50] shelever at ukrlink dot net

osCommerce 2.2-MS2 gets same error when open admin folder. Error in
file includes/classes/upload.php. 
On Windows/IIS5/ISAPI.

Resolwed by commenting:
// self destruct
//  $this = null;

Worked at PHP4

Good Luck!



[2004-07-22 15:28:08] mschulznospam at qualserv dot net

Expected behavior is if a script that works in PHP 4 also works in PHP
5.  This is definitely a bug, whether it's a bug in PHP or a bug in the
script.  But this broke a whole bunch of scripts on our servers so I'm
blaming PHP.

(remove the nospam in my email address if u want to reply)



[2004-07-21 18:00:33] drew at estara dot com

Anyone who knows PHP objects better than me, as a simple replacement
for:

$this = $foo;

will something like this:

foreach (get_object_vars($foo) as $key => $value)
  $this->$key = $value;

work in all cases?  It's worked in all the cases I've tested it on so
far (including Gallery), but I figure there must be a problem with it
since no one's mentioned it so far.

Drew



[2004-07-15 23:26:06] mlemos at acm dot org

There is no assignment of $this in Metabase code. It was a
misunderstanding of the original poster. Metabase works seeminglessly
in PHP 3, PHP 4 and PHP 5.



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27659

-- 
Edit this bug report at http://bugs.php.net/?id=27659&edit=1


#27659 [Com]: Cannot re-assign $this

2004-08-23 Thread shelever at ukrlink dot net
 ID:   27659
 Comment by:   shelever at ukrlink dot net
 Reported By:  js at enradia dot com
 Status:   Bogus
 Bug Type: Unknown/Other Function
 Operating System: linux 2.6.3
 PHP Version:  5.0.0RC1
 New Comment:

osCommerce 2.2-MS2 gets same error when open admin folder. Error in
file includes/classes/upload.php. 
On Windows/IIS5/ISAPI.

Resolwed by commenting:
// self destruct
//  $this = null;

Worked at PHP4

Good Luck!


Previous Comments:


[2004-07-22 15:28:08] mschulznospam at qualserv dot net

Expected behavior is if a script that works in PHP 4 also works in PHP
5.  This is definitely a bug, whether it's a bug in PHP or a bug in the
script.  But this broke a whole bunch of scripts on our servers so I'm
blaming PHP.

(remove the nospam in my email address if u want to reply)



[2004-07-21 18:00:33] drew at estara dot com

Anyone who knows PHP objects better than me, as a simple replacement
for:

$this = $foo;

will something like this:

foreach (get_object_vars($foo) as $key => $value)
  $this->$key = $value;

work in all cases?  It's worked in all the cases I've tested it on so
far (including Gallery), but I figure there must be a problem with it
since no one's mentioned it so far.

Drew



[2004-07-15 23:26:06] mlemos at acm dot org

There is no assignment of $this in Metabase code. It was a
misunderstanding of the original poster. Metabase works seeminglessly
in PHP 3, PHP 4 and PHP 5.



[2004-07-15 02:49:27] jbeall at heraldic dot us

Here is a potential solution.  Where you would have reassigned $this,
do something like this:

$this->Object = new Whatever();

Or, in the case of unserializing session data

$this->Session = unserialize($data);

Now you have a choice.  Your first option is to delegate every method
that needs to be delegated.  So, $this would need methods for every
method in $Object.  Each method would look something like:


function nameOfFunction()
{
 return $this->Object->nameOfFunction();
}

The other option is to intercept all method calls, and then decide on
the fly if they belong to $this or to $this->Object.

If you have properties, I think you are going to have to intercept with
__get() and __set().

You can read about overloading object functions with __get(), __set(),
and __call() here:
http://us2.php.net/manual/en/migration5.oop.php#migration5.oop.overload

I chose the delegation model.  If possible, I would recommend that.  If
you have properties to deal with, you will have to intercept the __get()
and __set() calls and handle them appropriately.



[2004-03-23 14:40:09] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Actually this is expected behavior. We explicitly decided to have $this
being readonly because of interna problems with the new engine.



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27659

-- 
Edit this bug report at http://bugs.php.net/?id=27659&edit=1


#27659 [Com]: Cannot re-assign $this

2004-07-22 Thread mschulznospam at qualserv dot net
 ID:   27659
 Comment by:   mschulznospam at qualserv dot net
 Reported By:  js at enradia dot com
 Status:   Bogus
 Bug Type: Unknown/Other Function
 Operating System: linux 2.6.3
 PHP Version:  5.0.0RC1
 New Comment:

Expected behavior is if a script that works in PHP 4 also works in PHP
5.  This is definitely a bug, whether it's a bug in PHP or a bug in the
script.  But this broke a whole bunch of scripts on our servers so I'm
blaming PHP.

(remove the nospam in my email address if u want to reply)


Previous Comments:


[2004-07-21 18:00:33] drew at estara dot com

Anyone who knows PHP objects better than me, as a simple replacement
for:

$this = $foo;

will something like this:

foreach (get_object_vars($foo) as $key => $value)
  $this->$key = $value;

work in all cases?  It's worked in all the cases I've tested it on so
far (including Gallery), but I figure there must be a problem with it
since no one's mentioned it so far.

Drew



[2004-07-15 23:26:06] mlemos at acm dot org

There is no assignment of $this in Metabase code. It was a
misunderstanding of the original poster. Metabase works seeminglessly
in PHP 3, PHP 4 and PHP 5.



[2004-07-15 02:49:27] jbeall at heraldic dot us

Here is a potential solution.  Where you would have reassigned $this,
do something like this:

$this->Object = new Whatever();

Or, in the case of unserializing session data

$this->Session = unserialize($data);

Now you have a choice.  Your first option is to delegate every method
that needs to be delegated.  So, $this would need methods for every
method in $Object.  Each method would look something like:


function nameOfFunction()
{
 return $this->Object->nameOfFunction();
}

The other option is to intercept all method calls, and then decide on
the fly if they belong to $this or to $this->Object.

If you have properties, I think you are going to have to intercept with
__get() and __set().

You can read about overloading object functions with __get(), __set(),
and __call() here:
http://us2.php.net/manual/en/migration5.oop.php#migration5.oop.overload

I chose the delegation model.  If possible, I would recommend that.  If
you have properties to deal with, you will have to intercept the __get()
and __set() calls and handle them appropriately.



[2004-03-23 14:40:09] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Actually this is expected behavior. We explicitly decided to have $this
being readonly because of interna problems with the new engine.



[2004-03-23 13:57:53] [EMAIL PROTECTED]

Take a look at PEAR::DB for an example of using a factory method (i.e.:
  $foo = DB::connect($uri);  )

For background on why support for reassigning $this was dropped, take a
look at http://news.php.net ( php.internals mailing list in particular )
or the ZendEngine2 mailing list which is archived at
http://www.zend.com




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27659

-- 
Edit this bug report at http://bugs.php.net/?id=27659&edit=1


#27659 [Com]: Cannot re-assign $this

2004-07-21 Thread drew at estara dot com
 ID:   27659
 Comment by:   drew at estara dot com
 Reported By:  js at enradia dot com
 Status:   Bogus
 Bug Type: Unknown/Other Function
 Operating System: linux 2.6.3
 PHP Version:  5.0.0RC1
 New Comment:

Anyone who knows PHP objects better than me, as a simple replacement
for:

$this = $foo;

will something like this:

foreach (get_object_vars($foo) as $key => $value)
  $this->$key = $value;

work in all cases?  It's worked in all the cases I've tested it on so
far (including Gallery), but I figure there must be a problem with it
since no one's mentioned it so far.

Drew


Previous Comments:


[2004-07-15 23:26:06] mlemos at acm dot org

There is no assignment of $this in Metabase code. It was a
misunderstanding of the original poster. Metabase works seeminglessly
in PHP 3, PHP 4 and PHP 5.



[2004-07-15 02:49:27] jbeall at heraldic dot us

Here is a potential solution.  Where you would have reassigned $this,
do something like this:

$this->Object = new Whatever();

Or, in the case of unserializing session data

$this->Session = unserialize($data);

Now you have a choice.  Your first option is to delegate every method
that needs to be delegated.  So, $this would need methods for every
method in $Object.  Each method would look something like:


function nameOfFunction()
{
 return $this->Object->nameOfFunction();
}

The other option is to intercept all method calls, and then decide on
the fly if they belong to $this or to $this->Object.

If you have properties, I think you are going to have to intercept with
__get() and __set().

You can read about overloading object functions with __get(), __set(),
and __call() here:
http://us2.php.net/manual/en/migration5.oop.php#migration5.oop.overload

I chose the delegation model.  If possible, I would recommend that.  If
you have properties to deal with, you will have to intercept the __get()
and __set() calls and handle them appropriately.



[2004-03-23 14:40:09] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Actually this is expected behavior. We explicitly decided to have $this
being readonly because of interna problems with the new engine.



[2004-03-23 13:57:53] [EMAIL PROTECTED]

Take a look at PEAR::DB for an example of using a factory method (i.e.:
  $foo = DB::connect($uri);  )

For background on why support for reassigning $this was dropped, take a
look at http://news.php.net ( php.internals mailing list in particular )
or the ZendEngine2 mailing list which is archived at
http://www.zend.com




[2004-03-23 13:52:42] js at enradia dot com

There is a _LOT_ of code out there using that. Metabase 
among others. Is there an alternative?  This could be a 
huge problem if there is none. 
 
Thanks



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27659

-- 
Edit this bug report at http://bugs.php.net/?id=27659&edit=1


#27659 [Com]: Cannot re-assign $this

2004-07-15 Thread mlemos at acm dot org
 ID:   27659
 Comment by:   mlemos at acm dot org
 Reported By:  js at enradia dot com
 Status:   Bogus
 Bug Type: Unknown/Other Function
 Operating System: linux 2.6.3
 PHP Version:  5.0.0RC1
 New Comment:

There is no assignment of $this in Metabase code. It was a
misunderstanding of the original poster. Metabase works seeminglessly
in PHP 3, PHP 4 and PHP 5.


Previous Comments:


[2004-07-15 02:49:27] jbeall at heraldic dot us

Here is a potential solution.  Where you would have reassigned $this,
do something like this:

$this->Object = new Whatever();

Or, in the case of unserializing session data

$this->Session = unserialize($data);

Now you have a choice.  Your first option is to delegate every method
that needs to be delegated.  So, $this would need methods for every
method in $Object.  Each method would look something like:


function nameOfFunction()
{
 return $this->Object->nameOfFunction();
}

The other option is to intercept all method calls, and then decide on
the fly if they belong to $this or to $this->Object.

If you have properties, I think you are going to have to intercept with
__get() and __set().

You can read about overloading object functions with __get(), __set(),
and __call() here:
http://us2.php.net/manual/en/migration5.oop.php#migration5.oop.overload

I chose the delegation model.  If possible, I would recommend that.  If
you have properties to deal with, you will have to intercept the __get()
and __set() calls and handle them appropriately.



[2004-03-23 14:40:09] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Actually this is expected behavior. We explicitly decided to have $this
being readonly because of interna problems with the new engine.



[2004-03-23 13:57:53] [EMAIL PROTECTED]

Take a look at PEAR::DB for an example of using a factory method (i.e.:
  $foo = DB::connect($uri);  )

For background on why support for reassigning $this was dropped, take a
look at http://news.php.net ( php.internals mailing list in particular )
or the ZendEngine2 mailing list which is archived at
http://www.zend.com




[2004-03-23 13:52:42] js at enradia dot com

There is a _LOT_ of code out there using that. Metabase 
among others. Is there an alternative?  This could be a 
huge problem if there is none. 
 
Thanks



[2004-03-23 13:38:14] [EMAIL PROTECTED]

This "feature" was undocumented in PHP4 and was never intended to work.
 



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27659

-- 
Edit this bug report at http://bugs.php.net/?id=27659&edit=1


#27659 [Com]: Cannot re-assign $this

2004-07-14 Thread jbeall at heraldic dot us
 ID:   27659
 Comment by:   jbeall at heraldic dot us
 Reported By:  js at enradia dot com
 Status:   Bogus
 Bug Type: Unknown/Other Function
 Operating System: linux 2.6.3
 PHP Version:  5.0.0RC1
 New Comment:

Here is a potential solution.  Where you would have reassigned $this,
do something like this:

$this->Object = new Whatever();

Or, in the case of unserializing session data

$this->Session = unserialize($data);

Now you have a choice.  Your first option is to delegate every method
that needs to be delegated.  So, $this would need methods for every
method in $Object.  Each method would look something like:


function nameOfFunction()
{
 return $this->Object->nameOfFunction();
}

The other option is to intercept all method calls, and then decide on
the fly if they belong to $this or to $this->Object.

If you have properties, I think you are going to have to intercept with
__get() and __set().

You can read about overloading object functions with __get(), __set(),
and __call() here:
http://us2.php.net/manual/en/migration5.oop.php#migration5.oop.overload

I chose the delegation model.  If possible, I would recommend that.  If
you have properties to deal with, you will have to intercept the __get()
and __set() calls and handle them appropriately.


Previous Comments:


[2004-03-23 14:40:09] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Actually this is expected behavior. We explicitly decided to have $this
being readonly because of interna problems with the new engine.



[2004-03-23 13:57:53] [EMAIL PROTECTED]

Take a look at PEAR::DB for an example of using a factory method (i.e.:
  $foo = DB::connect($uri);  )

For background on why support for reassigning $this was dropped, take a
look at http://news.php.net ( php.internals mailing list in particular )
or the ZendEngine2 mailing list which is archived at
http://www.zend.com




[2004-03-23 13:52:42] js at enradia dot com

There is a _LOT_ of code out there using that. Metabase 
among others. Is there an alternative?  This could be a 
huge problem if there is none. 
 
Thanks



[2004-03-23 13:38:14] [EMAIL PROTECTED]

This "feature" was undocumented in PHP4 and was never intended to work.
 



[2004-03-23 13:09:12] js at enradia dot com

Description:

When trying to reassign $this (from session data for 
example) I get an error: 
Fatal error: Cannot re-assign $this in... 
 
Code used: 
$this = unserialize($data); 
 
This works in php 4. Perhaps this is a feature change but 
I could not find a reference to any alternatives so I am 
submitting a bug just in case. 
 
Thanks! 
Joshua 

Reproduce code:
---
$this = unserialize($data);

Expected result:

Assignment of session or serialized data to $this object 

Actual result:
--
Fatal error: Cannot re-assign $this in... 
 





-- 
Edit this bug report at http://bugs.php.net/?id=27659&edit=1