Bug #53903 [Opn]: streamwrapper/stream_stat causes problems

From: Date: Tue, 01 Feb 2011 19:24:03 +0000
Subject: Bug #53903 [Opn]: streamwrapper/stream_stat causes problems
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-158415@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53903&edit=1

 ID:                 53903
 User updated by:    acid at rizzt dot kicks-ass dot org
 Reported by:        acid at rizzt dot kicks-ass dot org
 Summary:            streamwrapper/stream_stat causes problems
 Status:             Open
 Type:               Bug
 Package:            Streams related
 Operating System:   linux
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

Here is an entire script:

# php x.php

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


<?php

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');

file_get_contents('sx://test');

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

print_r($s);

?


Previous Comments:
------------------------------------------------------------------------
[2011-02-01 15:58:55] acid at rizzt dot kicks-ass dot org

Description:
------------
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,
    );

  }
}



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53903&edit=1


Thread (5 messages)

« previous php.bugs (#158415) next »