php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48004 Error handler prevents creation of default object
Submitted: 2009-04-17 11:27 UTC Modified: 2009-04-21 08:12 UTC
From: daniel dot mueller at inexio dot net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS, 6CVS (2009-04-20) OS: *
Private report: No CVE-ID: None
 [2009-04-17 11:27 UTC] daniel dot mueller at inexio dot net
Description:
------------
The creation of a default object from an empty value triggers a warning
with level E_STRICT.

If an error handler catches this warning, in some cases the automatic
initialization of the object fails.

Without error handler, everything works as expected.

Affected versions: 5.3.0RC1, 5.3.0alpha3
Not affected: 5.2.x 

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

function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
        return true;
}

function test()
{
        $data->id = 1;
        var_dump($data);
}

set_error_handler("error_handler");

test();


Expected result:
----------------
object(stdClass)#1 (1) {
  ["id"]=>
  int(1)
}


Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-17 19:02 UTC] daniel dot mueller at inexio dot net
The problem also exists in the latest CVS snapshot from today.
 [2009-04-20 15:58 UTC] jani@php.net
Works with PHP_5_2, fails with PHP_5_3 and HEAD:

==5779== 20 bytes in 1 blocks are definitely lost in loss record 2 of 9
==5779==    at 0x4006AEE: malloc (vg_replace_malloc.c:207)
==5779==    by 0x8350A92: _emalloc (zend_alloc.c:2304)
==5779==    by 0x83C74CA: zend_assign_to_object (zend_execute.c:539)
==5779==    by 0x841708A: ZEND_ASSIGN_OBJ_SPEC_CV_CONST_HANDLER (zend_vm_execute.h:23970)
==5779==    by 0x839CB24: execute (zend_vm_execute.h:104)
==5779==    by 0x83721EA: zend_execute_scripts (zend.c:1188)
==5779==    by 0x83050F7: php_execute_script (main.c:2157)
==5779==    by 0x8436E26: main (php_cli.c:1188)

 [2009-04-21 08:12 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 20:01:28 2024 UTC