#36883 [NEW]: debug_backtrace information has mixed scope
From: k at phpkoala dot com Operating system: Linux PHP version: 5.1.2 PHP Bug Type: Scripting Engine problem Bug description: debug_backtrace information has mixed scope Description: When I call debug_backtrace, I find that the results do not match expectations. Specifically, the line number does not match the values for function and class. As shown below, I would expect to see the line number match the values for function and class, at the point referenced. If this point is deemed to be the point where debug_backtrace is called from, then I would expect the details to show the function and class in scope at the line number that debug_backtrace was called, and then as the next most recent entry, the line number etc. for the code that called the function containing the debug_backtrace command. Otherwise, if the reported details should ignore the point in the code that calls debug_backtrace (the current scope at that point) then that entry should not be reported, and the function and class should be relative to the line number that called the function. It would appear that the second of these two options is intended, but that the function and class are being reported for the scope "now" (when debug_backtrace is called) rather than "then" (the last call, i.e. the call to the function) which is what the line number reports. To further clarify; I would expect the output to match the details that would be shown if I used __FILE__, __LINE__, __FUNCTION__, __CLASS__ at each call point. Surely these should all match up...? I am running dot-deb packages for PHP 5.1.2. No customisations. This issue also occurs on PHP 4.3.10. Reproduce code: --- Array ( [file] => /home/test.php [line] => 13 [function] => [class] => [type] => [args] => ) ) Test 2: Array ( [0] => Array ( [file] => /home/test.php [line] => 8 [function] => check2 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 16 [function] => [class] => [type] => [args] => ) ) OR Test 1: Array ( [0] => Array ( [file] => /home/test.php [line] => 5 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 13 [function] => [class] => [type] => [args] => ) ) Test 2: Array ( [0] => Array ( [file] => /home/test.php [line] => 5 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 8 [function] => check2 [class] => test [type] => :: [args] => Array ( ) ) [2] => Array ( [file] => /home/test.php [line] => 16 [function] => [class] => [type] => [args] => ) ) Actual result: -- Test 1: Array ( [0] => Array ( [file] => /home/test.php [line] => 13 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) ) Test 2: Array ( [0] => Array ( [file] => /home/test.php [line] => 8 [function] => check1 [class] => test [type] => :: [args] => Array ( ) ) [1] => Array ( [file] => /home/test.php [line] => 16 [function] => check2 [class] => test [type] => :: [args] => Array ( ) ) ) -- Edit bug report at http://bugs.php.net/?id=36883&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36883&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36883&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36883&
#36971 [NEW]: unset() no longer works on $this in PHP5
From: k at phpkoala dot com Operating system: Linux PHP version: 5.1.2 PHP Bug Type: Class/Object related Bug description: unset() no longer works on $this in PHP5 Description: In PHP4, calling unset($this) within a class worked fine, and destroyed that class instance. This was a very useful way technique, one that I and others have used many times. In PHP5, it simply no longer works. There is no error message - not even a strict - the instance is just unaffected. PHP4 also offers another method - setting $this = NULL, but PHP5 gives an error that $this cannot be reassigned. I would like to see this functionality restored, or, an alternate mechanism for destroying class instances internally should be pointed out (and put into the manual), or, if for some unknown reason this useful functionality is now declared by the PHP staff to be evil, the reasons should be revealed and the appropriate details put into the manual so that we know it know longer works in PHP5, and why. I figure it's just a bug ;) Reproduce code: --- class test { function f1() { unset($this); } function f2() { $this = NULL; } } $obj = new test; var_dump($obj); $obj->f1(); var_dump($obj); $obj->f2(); var_dump($obj); unset($obj); var_dump($obj); Expected result: object(test)(0) { } NULL NULL NULL Note: if f1() worked, there would be no need to run f2(), because $obj would have been unset. But, both methods should result in $obj being NULL. OR: object(test)(0) { } object(test)(0) { } NULL NULL This would also be an acceptable result, because there is an alternate method (f2()) that can be used. This is the result from the latest version of PHP4. Actual result: -- >From PHP5: Fatal error: Cannot re-assign $this in /home/test2.php on line 6 So, f2(), which sets $this to NULL, doesn't work. Commenting that out produces: object(test)#1 (0) { } object(test)#1 (0) { } NULL So, neither of the methods f1() or f2() work. >From the latest version of PHP4: object(test)(0) { } object(test)(0) { } NULL NULL This is fine, as the desired effect can still be accomplished. In earlier versions of PHP4, both f1() and f2() work fine. -- Edit bug report at http://bugs.php.net/?id=36971&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36971&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36971&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36971&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36971&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36971&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36971&r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=36971&r=needscript Try newer version:http://bugs.php.net/fix.php?id=36971&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36971&r=support Expected behavior:http://bugs.php.net/fix.php?id=36971&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36971&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36971&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36971&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36971&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36971&r=dst IIS Stability:http://bugs.php.net/fix.php?id=36971&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36971&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36971&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36971&r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=36971&r=mysqlcfg
#36971 [Bgs->Opn]: unset() no longer works on $this in PHP5
ID: 36971 User updated by: k at phpkoala dot com Reported By: k at phpkoala dot com -Status: Bogus +Status: Open Bug Type: Class/Object related Operating System: Linux PHP Version: 5.1.2 New Comment: Mike, I am serious or I would not have taken the time to post this bug report. The manual page for unset, over at http://www.php.net/manual/en/function.unset.php, does not mention this change in functionality. Like I said in my first message, this is something that works in PHP4 but no longer works in PHP5. If you can't believe I am serious, please point out why you think this is a joke? How do you destroy a class instance internally in PHP5? And if this is never going to happen, can't you say this in the manual, along with an explanation? If nothing else, the very fact that it worked in PHP4 and does not work in PHP5 should merit a mention in the documentation. (Just Google for this issue and you will see many pieces of software that have broken because of this, when used on PHP5.) Back to you, Mike. Previous Comments: [2006-04-04 19:33:07] [EMAIL PROTECTED] I can't believe you're serious. [2006-04-04 19:25:26] k at phpkoala dot com Description: In PHP4, calling unset($this) within a class worked fine, and destroyed that class instance. This was a very useful way technique, one that I and others have used many times. In PHP5, it simply no longer works. There is no error message - not even a strict - the instance is just unaffected. PHP4 also offers another method - setting $this = NULL, but PHP5 gives an error that $this cannot be reassigned. I would like to see this functionality restored, or, an alternate mechanism for destroying class instances internally should be pointed out (and put into the manual), or, if for some unknown reason this useful functionality is now declared by the PHP staff to be evil, the reasons should be revealed and the appropriate details put into the manual so that we know it know longer works in PHP5, and why. I figure it's just a bug ;) Reproduce code: --- class test { function f1() { unset($this); } function f2() { $this = NULL; } } $obj = new test; var_dump($obj); $obj->f1(); var_dump($obj); $obj->f2(); var_dump($obj); unset($obj); var_dump($obj); Expected result: object(test)(0) { } NULL NULL NULL Note: if f1() worked, there would be no need to run f2(), because $obj would have been unset. But, both methods should result in $obj being NULL. OR: object(test)(0) { } object(test)(0) { } NULL NULL This would also be an acceptable result, because there is an alternate method (f2()) that can be used. This is the result from the latest version of PHP4. Actual result: -- >From PHP5: Fatal error: Cannot re-assign $this in /home/test2.php on line 6 So, f2(), which sets $this to NULL, doesn't work. Commenting that out produces: object(test)#1 (0) { } object(test)#1 (0) { } NULL So, neither of the methods f1() or f2() work. >From the latest version of PHP4: object(test)(0) { } object(test)(0) { } NULL NULL This is fine, as the desired effect can still be accomplished. In earlier versions of PHP4, both f1() and f2() work fine. -- Edit this bug report at http://bugs.php.net/?id=36971&edit=1