|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53903 streamwrapper/stream_stat causes problems
Submitted: 2011-02-01 15:58 UTC Modified: 2011-02-01 23:55 UTC
From: acid at rizzt dot kicks-ass dot org Assigned: cataphract (profile)
Status: Closed Package: Streams related
PHP Version: 5.3.5 OS: linux
Private report: No CVE-ID: None
 [2011-02-01 15:58 UTC] acid at rizzt dot kicks-ass dot org
I experienced odd things testing code that was working with 5.2.19.

It look like reading a file with file_get_contents using a streamwrapper class 
destroys some part of the zend engine. After reading the file all sorts of odd 
problems occur.

I tracked it down to undefined variables returned by stream_stat() in my stream 
wrapper class. Casting the values to an integer fixes it.

Test script:
class StreamWrapper {
  public function stream_stat() {

    return array(
      'atime' => $this->notset,
      'mtime' => $this->notset,
      'ctime' => $this->notset,



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-01 20:24 UTC] acid at rizzt dot kicks-ass dot org
Here is an entire script:

# php x.php

Warning: Cannot use a scalar value as an array in x.php on line 30


class sw {

    public function stream_open($path, $mode, $options, &$opened_path) {
        return true;

    public function stream_read($count) {
		return FALSE;

    public function stream_eof() {
        return true;

	public function stream_stat() {
		return array(
            'atime' => $this->undefined,


stream_wrapper_register('sx', 'sw') or die('failed');


$s[] = 1; //  Cannot use a scalar value as an array


 [2011-02-01 20:54 UTC]
-Status: Open +Status: Verified
 [2011-02-01 21:52 UTC]
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2011-02-01 23:55 UTC]
Automatic comment from SVN on behalf of cataphract
Log: - Fixed bug #53903 (userspace stream stat callback does not separate the
  elements of the returned array before converting them).
 [2011-02-01 23:55 UTC]
-Status: Assigned +Status: Closed
 [2011-02-01 23:55 UTC]
Fixed in trunk and 5.3.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 16:01:28 2024 UTC