php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: damien at commerceguys dot com
New email:
PHP Version: OS:

 

 [2011-02-28 13:21 UTC] damien at commerceguys dot com
Description:
------------
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--
Test that user space streams do not break the fabric of the universe.
--FILE--
<?php

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');
fstat($h);

// ... 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';

?>
--EXPECTF--
Notice: Undefined index: size in %s on line %d



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-28 13:23 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-02-28 13:23 UTC] pajoye@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [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] cataphract@php.net
-Status: Open +Status: Duplicate
 [2011-02-28 17:09 UTC] cataphract@php.net
dup; already fixed in trunk
 [2011-02-28 19:22 UTC] pajoye@php.net
-Status: Duplicate +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2011-02-28 19:22 UTC] pajoye@php.net
please add the bug # or the revision of the previous fix.
 [2011-02-28 19:22 UTC] pajoye@php.net
-Operating System: Linux +Operating System:
 [2011-03-01 00:02 UTC] cataphract@php.net
-Status: Assigned +Status: Duplicate -Assigned To: cataphract +Assigned To:
 [2011-03-01 00:02 UTC] cataphract@php.net
bug #53903
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC