#36566 [Opn->Bgs]: offsetUnset after __get with dynamic params fails.

From: Date: Wed, 01 Mar 2006 09:29:24 +0000
Subject: #36566 [Opn->Bgs]: offsetUnset after __get with dynamic params fails.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93792@lists.php.net to get a copy of this message
ID: 36566 Updated by: tony2001@php.net Reported By: stochnagara at hotmail dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: win xp PHP Version: 5CVS-2006-03-01 (CVS) New Comment: Notice the difference between: 1) unset (objectPool()->{$module}[$id]); and 2) unset (objectPool()->{$module[$id]}); No bug here. Previous Comments: ------------------------------------------------------------------------ [2006-03-01 10:26:52] stochnagara at hotmail dot com And about <?php $m = 'o'; $p = 5; var_dump($m[$p]); ?> What do you expect to get in this case? NOT empty result? Why? So it seems that [] has a higher priority than -> in this case. It seems that is rather counterintuitive:( ------------------------------------------------------------------------ [2006-03-01 10:20:14] stochnagara at hotmail dot com Here is a more detailed sample: http://debian.fmi.uni-sofia.bg/~kapitancho/phpbug2.php ------------------------------------------------------------------------ [2006-03-01 09:44:46] tony2001@php.net You didn't answer my question. And I don't get why did you give the code that is not supposed to work at all. Provide a real reproduce code. ------------------------------------------------------------------------ [2006-03-01 09:25:28] stochnagara at hotmail dot com I've just simplified that test example to match bug reporting requirements for a short example. I will extend it a little so you can understand what I mean. I have a function called objectPool which returns an object of class Pool. Class Pool has a method __get which return an instance of an ORM class. The ORM class itself binds offsetUnset($id) to DELETE FROM table WHERE id=$id. I have a function that gets two parametes - $id and $module. I guarantee that this function receives correct parameters. I intended to use 'unset (objectPool()->$module[$id]);' so i get the ORM class for the module $module and delete its record with id $id. Unfortunately, PHP echoes the fatal error about the empty property. Now my workaround is this: $q = objectPool()->$module; unset ($q[$id]); which works perfect. I think that 'unset (objectPool()->$module[$id]);' should also work perfect. P.S. I've tested offsetExists, offsetSet and offsetUnset are also buggy. offsetSet also raises a fatal error, offsetExists always returns false and offsetGet returns as if it were 'objectPool()->$module' instead of 'objectPool()->$module[$id]' ------------------------------------------------------------------------ [2006-03-01 08:37:48] tony2001@php.net <?php $m = 'o'; $p = 5; var_dump($m[$p]); ?> What do you expect to get in this case? NOT empty result? Why? ------------------------------------------------------------------------ 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/36566 -- Edit this bug report at http://bugs.php.net/?id=36566&edit=1

« previous php.bugs (#93792) next »