#40604 [NEW]: Objects disappear from the global scope

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

  1. #1

    Default #40604 [NEW]: Objects disappear from the global scope

    From: dagdamor at simps dot ru
    Operating system: Windows
    PHP version: 5.2.1
    PHP Bug Type: Class/Object related
    Bug description: Objects disappear from the global scope

    Description:
    ------------
    Objects seem to disappear from the global scope when you try to access
    them from the output buffer callback function. Regular variables (i.e. not
    objects) don't disappear and work alright.

    After some additional research I've noticed that if your PHP program has
    many objects in the global scope, some of them don't disappear, while
    others do. Looks very strange...

    I hope this is not documentation misinterpretation, because I used global
    variables, objects including in OB callbacks in PHP4, and it worked fine.
    In other words, I hope this is not "You can't use global variables there"
    case.

    Reproduce code:
    ---------------
    <?php

    function handler($content)
    {
    global $obj;
    return isset($obj)?"OK":"Error";
    }

    class MyClass {}
    $obj=new MyClass();

    ob_start("handler");

    ?>

    Expected result:
    ----------------
    OK

    Actual result:
    --------------
    Error

    --
    Edit bug report at [url]http://bugs.php.net/?id=40604&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40604&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40604&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40604&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40604&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40604&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40604&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40604&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40604&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40604&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40604&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40604&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40604&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40604&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40604&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40604&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40604&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40604&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40604&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40604&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40604&r=mysqlcfg[/url]
    dagdamor at simps dot ru Guest

  2. Similar Questions and Discussions

    1. Global Variables and scope
      Ok, I'm creating a fairly large RIA using many components set on a page. They all share a common list. It is a Project list that is displayed in a...
    2. Problem with sessions (in global scope vs class scope)
      Hello, i'me having a wierd problems with sessions. PHP 4.3.3, Register globals is on, and the sessions module is installed. if i have a page like...
    3. [PHP] global scope issue
      does it matter if a global command has bee issued before with vars other than the $test var? i.e before the include if there is a global $somevar;...
    4. global scope issue
      "Shawn McKenzie" <nospam@mckenzies.net> wrote in message news:20030813142705.28520.qmail@pb1.pair.com... the As far as I know, no defined variable...
    5. Help Please: 'Warning 5001 global variable "iF_timer" already defined in global scope
      Hi there, I have just started to get this error: 'Warning 5001 global variable "iF_timer" already defined in global scope The variable name...
  3. #2

    Default #40604 [Opn->Bgs]: Objects disappear from the global scope

    ID: 40604
    Updated by: [email]helly@php.net[/email]
    Reported By: dagdamor at simps dot ru
    -Status: Open
    +Status: Bogus
    Bug Type: Class/Object related
    Operating System: Windows
    PHP Version: 5.2.1
    New Comment:

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

    the object gets destroyed before you get output - well actually you
    don't produce output


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

    [2007-02-23 08:49:07] dagdamor at simps dot ru

    Description:
    ------------
    Objects seem to disappear from the global scope when you try to access
    them from the output buffer callback function. Regular variables (i.e.
    not objects) don't disappear and work alright.

    After some additional research I've noticed that if your PHP program
    has many objects in the global scope, some of them don't disappear,
    while others do. Looks very strange...

    I hope this is not documentation misinterpretation, because I used
    global variables, objects including in OB callbacks in PHP4, and it
    worked fine. In other words, I hope this is not "You can't use global
    variables there" case.

    Reproduce code:
    ---------------
    <?php

    function handler($content)
    {
    global $obj;
    return isset($obj)?"OK":"Error";
    }

    class MyClass {}
    $obj=new MyClass();

    ob_start("handler");

    ?>

    Expected result:
    ----------------
    OK

    Actual result:
    --------------
    Error


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40604&edit=1[/url]
    helly@php.net Guest

  4. #3

    Default #40604 [Bgs->Opn]: Objects disappear from the global scope

    ID: 40604
    User updated by: dagdamor at simps dot ru
    Reported By: dagdamor at simps dot ru
    -Status: Bogus
    +Status: Open
    Bug Type: Class/Object related
    Operating System: Windows
    PHP Version: 5.2.1
    New Comment:

    I didn't understand your reply at all :( could you please provide a bit
    more explanatory response?

    I see that the object gets destroyed before the script ends its work
    (since it's inaccessible in the provided example), but I don't
    understand why it's expected behavior... I never destroyed that object
    manually, and created it expecting it to work till the very end of
    script.


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

    [2007-02-23 09:04:55] [email]helly@php.net[/email]

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

    the object gets destroyed before you get output - well actually you
    don\'t produce output

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

    [2007-02-23 08:49:07] dagdamor at simps dot ru

    Description:
    ------------
    Objects seem to disappear from the global scope when you try to access
    them from the output buffer callback function. Regular variables (i.e.
    not objects) don't disappear and work alright.

    After some additional research I've noticed that if your PHP program
    has many objects in the global scope, some of them don't disappear,
    while others do. Looks very strange...

    I hope this is not documentation misinterpretation, because I used
    global variables, objects including in OB callbacks in PHP4, and it
    worked fine. In other words, I hope this is not "You can't use global
    variables there" case.

    Reproduce code:
    ---------------
    <?php

    function handler($content)
    {
    global $obj;
    return isset($obj)?"OK":"Error";
    }

    class MyClass {}
    $obj=new MyClass();

    ob_start("handler");

    ?>

    Expected result:
    ----------------
    OK

    Actual result:
    --------------
    Error


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40604&edit=1[/url]
    dagdamor at simps dot ru Guest

  5. #4

    Default #40604 [Opn->Bgs]: Objects disappear from the global scope

    ID: 40604
    Updated by: [email]tony2001@php.net[/email]
    Reported By: dagdamor at simps dot ru
    -Status: Open
    +Status: Bogus
    Bug Type: Class/Object related
    Operating System: Windows
    PHP Version: 5.2.1
    New Comment:

    All objects are destroyed _before_ output callbacks are called.


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

    [2007-02-23 23:26:59] dagdamor at simps dot ru

    I didn't understand your reply at all :( could you please provide a bit
    more explanatory response?

    I see that the object gets destroyed before the script ends its work
    (since it's inaccessible in the provided example), but I don't
    understand why it's expected behavior... I never destroyed that object
    manually, and created it expecting it to work till the very end of
    script.

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

    [2007-02-23 09:04:55] [email]helly@php.net[/email]

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

    the object gets destroyed before you get output - well actually you
    don\'t produce output

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

    [2007-02-23 08:49:07] dagdamor at simps dot ru

    Description:
    ------------
    Objects seem to disappear from the global scope when you try to access
    them from the output buffer callback function. Regular variables (i.e.
    not objects) don't disappear and work alright.

    After some additional research I've noticed that if your PHP program
    has many objects in the global scope, some of them don't disappear,
    while others do. Looks very strange...

    I hope this is not documentation misinterpretation, because I used
    global variables, objects including in OB callbacks in PHP4, and it
    worked fine. In other words, I hope this is not "You can't use global
    variables there" case.

    Reproduce code:
    ---------------
    <?php

    function handler($content)
    {
    global $obj;
    return isset($obj)?"OK":"Error";
    }

    class MyClass {}
    $obj=new MyClass();

    ob_start("handler");

    ?>

    Expected result:
    ----------------
    OK

    Actual result:
    --------------
    Error


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40604&edit=1[/url]
    tony2001@php.net Guest

  6. #5

    Default #40604 [Bgs]: Objects disappear from the global scope

    ID: 40604
    User updated by: dagdamor at simps dot ru
    Reported By: dagdamor at simps dot ru
    Status: Bogus
    Bug Type: Class/Object related
    Operating System: Windows
    PHP Version: 5.2.1
    New Comment:

    Okay... I understand.

    But since it's not obvious and is a BC break, maybe it makes sense to
    write about the issue in the documentation? (For example, in the Output
    Control section.) I don't want anyone else to stand on the same rake.


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

    [2007-02-23 23:33:43] [email]tony2001@php.net[/email]

    All objects are destroyed _before_ output callbacks are called.

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

    [2007-02-23 23:26:59] dagdamor at simps dot ru

    I didn't understand your reply at all :( could you please provide a bit
    more explanatory response?

    I see that the object gets destroyed before the script ends its work
    (since it's inaccessible in the provided example), but I don't
    understand why it's expected behavior... I never destroyed that object
    manually, and created it expecting it to work till the very end of
    script.

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

    [2007-02-23 09:04:55] [email]helly@php.net[/email]

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

    the object gets destroyed before you get output - well actually you
    don\'t produce output

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

    [2007-02-23 08:49:07] dagdamor at simps dot ru

    Description:
    ------------
    Objects seem to disappear from the global scope when you try to access
    them from the output buffer callback function. Regular variables (i.e.
    not objects) don't disappear and work alright.

    After some additional research I've noticed that if your PHP program
    has many objects in the global scope, some of them don't disappear,
    while others do. Looks very strange...

    I hope this is not documentation misinterpretation, because I used
    global variables, objects including in OB callbacks in PHP4, and it
    worked fine. In other words, I hope this is not "You can't use global
    variables there" case.

    Reproduce code:
    ---------------
    <?php

    function handler($content)
    {
    global $obj;
    return isset($obj)?"OK":"Error";
    }

    class MyClass {}
    $obj=new MyClass();

    ob_start("handler");

    ?>

    Expected result:
    ----------------
    OK

    Actual result:
    --------------
    Error


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40604&edit=1[/url]
    dagdamor at simps dot ru Guest

  7. #6

    Default #40604 [Bgs]: Objects disappear from the global scope

    ID: 40604
    Updated by: [email]tony2001@php.net[/email]
    Reported By: dagdamor at simps dot ru
    Status: Bogus
    Bug Type: Class/Object related
    Operating System: Windows
    PHP Version: 5.2.1
    New Comment:
    >But since it's not obvious and is a BC break
    BC break? This behaviour exists at least since 5.1.0.
    And this can't be a BC break comparing to PHP4, for classes in PHP4 do
    not have any destructors.
    >maybe it makes sense to write about the issue in the documentation?
    Probably.
    I'm sure the documentation team would appreciate any help.


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

    [2007-02-23 23:46:42] dagdamor at simps dot ru

    Okay... I understand.

    But since it's not obvious and is a BC break, maybe it makes sense to
    write about the issue in the documentation? (For example, in the Output
    Control section.) I don't want anyone else to stand on the same rake.

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

    [2007-02-23 23:33:43] [email]tony2001@php.net[/email]

    All objects are destroyed _before_ output callbacks are called.

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

    [2007-02-23 23:26:59] dagdamor at simps dot ru

    I didn't understand your reply at all :( could you please provide a bit
    more explanatory response?

    I see that the object gets destroyed before the script ends its work
    (since it's inaccessible in the provided example), but I don't
    understand why it's expected behavior... I never destroyed that object
    manually, and created it expecting it to work till the very end of
    script.

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

    [2007-02-23 09:04:55] [email]helly@php.net[/email]

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

    the object gets destroyed before you get output - well actually you
    don\'t produce output

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

    [2007-02-23 08:49:07] dagdamor at simps dot ru

    Description:
    ------------
    Objects seem to disappear from the global scope when you try to access
    them from the output buffer callback function. Regular variables (i.e.
    not objects) don't disappear and work alright.

    After some additional research I've noticed that if your PHP program
    has many objects in the global scope, some of them don't disappear,
    while others do. Looks very strange...

    I hope this is not documentation misinterpretation, because I used
    global variables, objects including in OB callbacks in PHP4, and it
    worked fine. In other words, I hope this is not "You can't use global
    variables there" case.

    Reproduce code:
    ---------------
    <?php

    function handler($content)
    {
    global $obj;
    return isset($obj)?"OK":"Error";
    }

    class MyClass {}
    $obj=new MyClass();

    ob_start("handler");

    ?>

    Expected result:
    ----------------
    OK

    Actual result:
    --------------
    Error


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40604&edit=1[/url]
    tony2001@php.net 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