1--TEST-- 2GH-10834 (exif_read_data() cannot read smaller stream wrapper chunk sizes) 3--EXTENSIONS-- 4exif 5--FILE-- 6<?php 7class VariableStream { 8 private $data; 9 private $position; 10 public $context; 11 12 function stream_close() { 13 return true; 14 } 15 16 function stream_eof() { 17 return $this->position >= strlen($this->data); 18 } 19 20 function stream_open($path, $mode, $options, &$opened_path) { 21 $this->position = 0; 22 $this->data = file_get_contents(__DIR__.'/bug50845.jpg'); 23 return true; 24 } 25 26 function stream_seek($offset, $whence) { 27 switch ($whence) { 28 case SEEK_SET: 29 if ($offset < strlen($this->data) && $offset >= 0) { 30 $this->position = $offset; 31 return true; 32 } else { 33 return false; 34 } 35 break; 36 case SEEK_CUR: 37 if ($offset >= 0) { 38 $this->position += $offset; 39 return true; 40 } else { 41 return false; 42 } 43 break; 44 case SEEK_END: 45 if (strlen($this->data) + $offset >= 0) { 46 $this->position = strlen($this->data) + $offset; 47 return true; 48 } else { 49 return false; 50 } 51 break; 52 default: 53 return false; 54 } 55 } 56 57 function stream_read($count) { 58 $ret = substr($this->data, $this->position, $count); 59 $this->position += strlen($ret); 60 return $ret; 61 } 62 63 function stream_tell() { 64 return $this->position; 65 } 66} 67 68stream_wrapper_register('var', 'VariableStream'); 69 70$fp = fopen('var://myvar', 'rb'); 71 72stream_set_chunk_size($fp, 10); 73$headers = exif_read_data($fp); 74var_dump(is_array($headers)); 75 76fclose($fp); 77?> 78--EXPECT-- 79bool(true) 80