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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 19:01:29 2024 UTC