|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54119 Bogus behavior of Zend in relation to stream wrappers
Submitted: 2011-02-28 13:21 UTC Modified: 2011-03-01 00:02 UTC
From: damien at commerceguys dot com Assigned:
Status: Duplicate Package: Filesystem function related
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: damien at commerceguys dot com
New email:
PHP Version: OS:


 [2011-02-28 13:21 UTC] damien at commerceguys dot com
See test script: when returning a undefined key from stream_stat(), the behavior 
of the Zend interpretor changes.

I confirmed this on PHP 5.3.5, pjoye reproduced it separately.

Test script:
Test that user space streams do not break the fabric of the universe.

class UserSpaceStream {
  public function stream_open($uri, $mode, $options, &$opened_path) {
    return TRUE;

  public function stream_read($count) {
    return '';

  public function stream_write($data) {
    return TRUE;

  public function stream_eof() {
    return FALSE;

  public function stream_stat() {
    $stat = array();

    // This triggers (correctly) a "Notice: Undefined index: size in %s on line %d".
    $array = array();
    $stat['size'] = $array['size'];

    return $stat;


stream_wrapper_register("test", "UserSpaceStream");

// Alone, the assignment of a key to an undefined variable is legal.
$undefined_variable['key'] = 'value';

// This fstat() call triggers something weird...
$h = fopen('test://anyfile', 'r');

// ... from this point, PHP triggers a "Warning: Cannot use a scalar value as
// an array" for each assignement of array keys to undefined variables.
$undefined_variable2['key'] = 'value';

Notice: Undefined index: size in %s on line %d


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-28 13:23 UTC]
-Status: Open +Status: Feedback
 [2011-02-28 13:23 UTC]
Please try using this snapshot:
For Windows:

 [2011-02-28 15:50 UTC] damien at commerceguys dot com
-Status: Feedback +Status: Open
 [2011-02-28 15:50 UTC] damien at commerceguys dot com
I can confirm this works on 5.3.6-dev. So this seems to have go fixed along the 
way, any idea where?
 [2011-02-28 17:08 UTC]
-Status: Open +Status: Duplicate
 [2011-02-28 17:09 UTC]
dup; already fixed in trunk
 [2011-02-28 19:22 UTC]
-Status: Duplicate +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2011-02-28 19:22 UTC]
please add the bug # or the revision of the previous fix.
 [2011-02-28 19:22 UTC]
-Operating System: Linux +Operating System:
 [2011-03-01 00:02 UTC]
-Status: Assigned +Status: Duplicate -Assigned To: cataphract +Assigned To:
 [2011-03-01 00:02 UTC]
bug #53903
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 23:01:27 2024 UTC