Edit report at https://bugs.php.net/bug.php?id=47154&edit=1

 ID:                 47154
 Updated by:         [email protected]
 Reported by:        onerax at gmail dot com
 Summary:            Object properties unset after setting.
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows
-PHP Version:        6CVS-2009-01-19 (snap)
+PHP Version:        5.3
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.




Previous Comments:
------------------------------------------------------------------------
[2009-01-21 22:21:16] onerax at gmail dot com

I've found a workaround for this problem.

Using extract($Data) I was able to assign $User->Password to the 
resulting $Password variable and get the correct value in place.

------------------------------------------------------------------------
[2009-01-20 23:12:05] onerax at gmail dot com

It also seems that if I set the values in the object manually - in 
the above example, $User->Password = 'notest', then the property is 
set. If I do the same to the array $Data, $Data['Password'] = 
'notest', It does not set the existing Password index, rather it 
creates a second Password index, which is shown in print_r below.

Array ( [EntityId] => USER_4974b612242741.58553835 [Password] => test 
[LastLogin] => [LastIp] => [Name] => test [Description] => [Updated] 
=> [Created] => 2009-01-19 17:19:14 [Parent] => [Owner] => [UserId] 
=> USER_4974b612242741.58553835 [FirstName] => [MiddleName] => 
[LastName] => [Avatar] => [Alias] => [Gender] => [Signature] => 
[Password] => notest ) 111Page Generation Time:: 0.09224 seconds

A single array with two "Password" entries...strange, yes? =)

------------------------------------------------------------------------
[2009-01-20 16:51:28] onerax at gmail dot com

Here's a section of the actual code piece, and the output of all 
involved variables after the routine.

CODE::
<?php
Namespace xBB\Database;
require_once('./Core/Database/EntityQueries.class.php');

class UserQueries extends EntityQueries
{
        public function Fill($User, Array &$Data)
        {
                parent::Fill($User, $Data);
                $User->Password = $Data['Password'];
                $User->LastLogin        = $Data['LastLogin'];
                $User->LastIp   = $Data['LastIp'];

                require_once('./Core/Entities/Profile.class.php');
                $User->Profile          = new 
\xBB\Entities\Profile();
                $User->Profile->UserId  = $Data['EntityId'];

                $this->Database->Profiles->Fill($User->Profile, 
$Data);
                if(sizeof($Data)>1){
                die(print_r($User).print_r($User-
>Profile).print_r($Data));
                }
        }
...


OUTPUT::
xBB\Entities\User Object ( [Password] => [LastLogin] => [Profile] => 
xBB\Entities\Profile Object ( [UserId] => [FirstName] => [MiddleName] 
=> [LastName] => [Avatar] => [Alias] => [Gender] => [Signature] => ) 
[LastIp] => [EntityId] => [Name] => [Description] => [Updated] => 
[Created] => [Parent] => [Owner] => ) xBB\Entities\Profile Object ( 
[UserId] => [FirstName] => [MiddleName] => [LastName] => [Avatar] => 
[Alias] => [Gender] => [Signature] => ) Array ( [EntityId] => 
USER_4974b612242741.58553835 [Password] => test [LastLogin] => 
[LastIp] => [Name] => test [Description] => [Updated] => [Created] => 
2009-01-19 17:19:14 [Parent] => [Owner] => [UserId] => 
USER_4974b612242741.58553835 [FirstName] => [MiddleName] => 
[LastName] => [Avatar] => [Alias] => [Gender] => [Signature] => ) 
111Page Generation Time:: 0.093775 seconds

------------------------------------------------------------------------
[2009-01-19 21:16:35] onerax at gmail dot com

Description:
------------
After setting object properties on one line, object is still empty on 
the next. Inheritance, multiple namespaces, and passing arrays by 
reference are involved.





Reproduce code:
---------------
http://helios-emu.org/arraytest.txt

keep in mind this is not the actual code, and does not reproduce the problem by 
itself. To reproduce the problem you have to separate each class into a 
separate file and separate them out into two separate namespaces. I have the 
original code that I uncovered this in and can e-mail it upon a developer's 
request, but I will not make it public.

Expected result:
----------------
The object in which the properties are set contain data.

Actual result:
--------------
The object in which the properties are set do not contain data.


------------------------------------------------------------------------



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

Reply via email to