#33314 [Com]: Child class variable change not propogated during function call

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #33314 [Com]: Child class variable change not propogated during function call

    ID: 33314
    Comment by: andrew at azarov dot com
    Reported By: gregory dot szorc at case dot edu
    Status: No Feedback
    Bug Type: Class/Object related
    Operating System: Linux (multiple)
    PHP Version: 5CVS-2005-06-12
    New Comment:

    class.php:
    <?
    class Test
    {
    var $Dynamic = Array();
    function Start()
    {
    $Dynamic = Array("test"=>"hope")
    $this->$Dynamic = $Dynamic;
    }
    function GetArray()
    {
    return $this->Dynamic;
    }
    }
    ?>
    test.php:
    <?
    require class.php;
    $file = new Test();
    $file->Start();
    print_r($file->Dynamic); // Will result in 'Array()'
    $s = $file->GetArray(); // Will result in 'Fatal error: Cannot access
    empty property'
    print_r($s)
    ?>


    Previous Comments:
    ------------------------------------------------------------------------

    [2005-06-23 01:00:04] php-bugs at lists dot php dot net

    No feedback was provided for this bug for over a week, so it is
    being suspended automatically. If you are able to provide the
    information that was originally requested, please do so and change
    the status of the bug back to "Open".

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

    [2005-06-15 18:14:28] [email]tony2001@php.net[/email]

    Gregory, if you provide an example (even relatively big) it would be
    MUCH easier for us to understand what are you talking about (and to fix
    it too).
    Please cook a script (okay, let it be BIG script), put it somewhere on
    the Net (no SVN and other exotic things please, just a plain HTTP) and
    give us the link.
    Thanks in advance.

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

    [2005-06-15 16:11:59] gregory dot szorc at case dot edu

    I have tried to recreate the problem by recreating the basic
    class hierarchy that exists in my project. Unfortunately, I
    have been unable to duplicate. I would gladly try and debug
    things myself, but I have no knowledge regarding debugging
    core PHP.

    The problem occurs in BaseLayout.php. It is reproducable
    through tests/iCal_create.php. The test program doesn't
    even involve a lot of the classes. Considering that the
    problem is an object reference being lost/ignored as it is
    passed back to a function, I would think this would be a
    relatively easy problem to debug. Who knows.

    If someone could provide instructions for how to debug this
    problem, I would attempt to do it myself.

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

    [2005-06-15 15:30:03] [email]sniper@php.net[/email]

    We _REALLY_ need a short reproducing script. We don't have time to go
    through hundreds of lines of code..


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

    [2005-06-14 16:58:33] gregory dot szorc at case dot edu

    As mentioned in the orignal post, I have not been able to
    reproduce the problem outside of the project from which I am
    working. Believe me, I tried. Read [url]http://zorro.case.edu/[/url]
    viewcvs/php_classes/File_iCal/trunk/File/iCal/
    BaseComponent.php?rev=119&view=markup around line 234 for a
    comment and the actual code that causes the bug to trigger.

    Given the way that the problem can be "solved," there is
    obviously a bug with the class support. Unfortunately, I
    can't reproduce it outside of the PEAR project on which I am
    working.

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

    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
    [url]http://bugs.php.net/33314[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=33314&edit=1[/url]
    andrew at azarov dot com Guest

  2. Similar Questions and Discussions

    1. #33314 [NoF->Opn]: Child class variable change not propogated during function call
      ID: 33314 User updated by: gregory dot szorc at case dot edu Reported By: gregory dot szorc at case dot edu -Status: ...
    2. How do I call an outer function from a class method function?
      I'm sorry guys but this is a bad day for me. I tried researching this one and was totally stonewalled (see...
    3. Why can a class call a function outside of itself?
      "Adams-Blake Co." <atakeoutcanton@adams.takeme.out.-blake.com> schrieb: It works in C++ e.g. You have to look at the code of the...
    4. call function as variable
      Hi! I have folowing function which they are a member in a class. function foo(){ something } function zoo(){ something else
    5. How do I call a function in a Class from another function in the same class
      Hi, I have two functions in a class where one calls the other. When creating my object I get an error: "Call to undefined function" I...
  3. #2

    Default #33314 [Com]: Child class variable change not propogated during function call

    ID: 33314
    Comment by: xstex2 at hotmail dot com
    Reported By: gregory dot szorc at case dot edu
    Status: No Feedback
    Bug Type: Class/Object related
    Operating System: Linux (multiple)
    PHP Version: 5CVS-2005-06-12
    New Comment:

    Any update on this issue?


    Previous Comments:
    ------------------------------------------------------------------------

    [2006-12-14 07:55:17] andrew at azarov dot com

    class.php:
    <?
    class Test
    {
    var $Dynamic = Array();
    function Start()
    {
    $Dynamic = Array("test"=>"hope")
    $this->$Dynamic = $Dynamic;
    }
    function GetArray()
    {
    return $this->Dynamic;
    }
    }
    ?>
    test.php:
    <?
    require class.php;
    $file = new Test();
    $file->Start();
    print_r($file->Dynamic); // Will result in 'Array()'
    $s = $file->GetArray(); // Will result in 'Fatal error: Cannot access
    empty property'
    print_r($s)
    ?>

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

    [2005-06-23 01:00:04] php-bugs at lists dot php dot net

    No feedback was provided for this bug for over a week, so it is
    being suspended automatically. If you are able to provide the
    information that was originally requested, please do so and change
    the status of the bug back to "Open".

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

    [2005-06-15 18:14:28] [email]tony2001@php.net[/email]

    Gregory, if you provide an example (even relatively big) it would be
    MUCH easier for us to understand what are you talking about (and to fix
    it too).
    Please cook a script (okay, let it be BIG script), put it somewhere on
    the Net (no SVN and other exotic things please, just a plain HTTP) and
    give us the link.
    Thanks in advance.

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

    [2005-06-15 16:11:59] gregory dot szorc at case dot edu

    I have tried to recreate the problem by recreating the basic
    class hierarchy that exists in my project. Unfortunately, I
    have been unable to duplicate. I would gladly try and debug
    things myself, but I have no knowledge regarding debugging
    core PHP.

    The problem occurs in BaseLayout.php. It is reproducable
    through tests/iCal_create.php. The test program doesn't
    even involve a lot of the classes. Considering that the
    problem is an object reference being lost/ignored as it is
    passed back to a function, I would think this would be a
    relatively easy problem to debug. Who knows.

    If someone could provide instructions for how to debug this
    problem, I would attempt to do it myself.

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

    [2005-06-15 15:30:03] [email]sniper@php.net[/email]

    We _REALLY_ need a short reproducing script. We don't have time to go
    through hundreds of lines of code..


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

    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
    [url]http://bugs.php.net/33314[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=33314&edit=1[/url]
    xstex2 at hotmail dot com Guest

  4. #3

    Default #33314 [Com]: Child class variable change not propogated during function call

    ID: 33314
    Comment by: confins_de_l_univers at yahoo dot fr
    Reported By: gregory dot szorc at case dot edu
    Status: No Feedback
    Bug Type: Class/Object related
    Operating System: Linux (multiple)
    PHP Version: 5CVS-2005-06-12
    New Comment:

    I think it's a typo error.

    In the Start() method, he use :
    $this->$Dynamic = $Dynamic;

    but he should use :
    $this->Dynamic = $Dynamic;

    so $this->Dynamic is not set when he call GetArray() method


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-06 01:08:22] xstex2 at hotmail dot com

    Any update on this issue?

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

    [2006-12-14 07:55:17] andrew at azarov dot com

    class.php:
    <?
    class Test
    {
    var $Dynamic = Array();
    function Start()
    {
    $Dynamic = Array("test"=>"hope")
    $this->$Dynamic = $Dynamic;
    }
    function GetArray()
    {
    return $this->Dynamic;
    }
    }
    ?>
    test.php:
    <?
    require class.php;
    $file = new Test();
    $file->Start();
    print_r($file->Dynamic); // Will result in 'Array()'
    $s = $file->GetArray(); // Will result in 'Fatal error: Cannot access
    empty property'
    print_r($s)
    ?>

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

    [2005-06-23 01:00:04] php-bugs at lists dot php dot net

    No feedback was provided for this bug for over a week, so it is
    being suspended automatically. If you are able to provide the
    information that was originally requested, please do so and change
    the status of the bug back to "Open".

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

    [2005-06-15 18:14:28] [email]tony2001@php.net[/email]

    Gregory, if you provide an example (even relatively big) it would be
    MUCH easier for us to understand what are you talking about (and to fix
    it too).
    Please cook a script (okay, let it be BIG script), put it somewhere on
    the Net (no SVN and other exotic things please, just a plain HTTP) and
    give us the link.
    Thanks in advance.

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

    [2005-06-15 16:11:59] gregory dot szorc at case dot edu

    I have tried to recreate the problem by recreating the basic
    class hierarchy that exists in my project. Unfortunately, I
    have been unable to duplicate. I would gladly try and debug
    things myself, but I have no knowledge regarding debugging
    core PHP.

    The problem occurs in BaseLayout.php. It is reproducable
    through tests/iCal_create.php. The test program doesn't
    even involve a lot of the classes. Considering that the
    problem is an object reference being lost/ignored as it is
    passed back to a function, I would think this would be a
    relatively easy problem to debug. Who knows.

    If someone could provide instructions for how to debug this
    problem, I would attempt to do it myself.

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

    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
    [url]http://bugs.php.net/33314[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=33314&edit=1[/url]
    confins_de_l_univers at yahoo dot fr Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139