mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
b32e9a9227
@ -22,6 +22,9 @@ class Loader {
|
||||
function stream_stat() {
|
||||
return array('size' => strlen($this->data));
|
||||
}
|
||||
function stream_set_option($option, $arg1, $arg2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
stream_wrapper_register('Loader', 'Loader');
|
||||
require 'Loader://qqq.php';
|
||||
|
@ -126,7 +126,7 @@ static size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t
|
||||
ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */
|
||||
{
|
||||
size_t size;
|
||||
zend_stream_type old_type;
|
||||
zend_bool is_fp = 0;
|
||||
|
||||
if (file_handle->buf) {
|
||||
*buf = file_handle->buf;
|
||||
@ -145,6 +145,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
is_fp = 1;
|
||||
file_handle->type = ZEND_HANDLE_STREAM;
|
||||
file_handle->handle.stream.handle = file_handle->handle.fp;
|
||||
file_handle->handle.stream.isatty = isatty(fileno((FILE *)file_handle->handle.stream.handle));
|
||||
@ -158,10 +159,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
old_type = file_handle->type;
|
||||
file_handle->type = ZEND_HANDLE_STREAM; /* we might still be _FP but we need fsize() work */
|
||||
|
||||
if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
|
||||
if (is_fp && !file_handle->handle.stream.isatty && size) {
|
||||
file_handle->buf = *buf = safe_emalloc(1, size, ZEND_MMAP_AHEAD);
|
||||
file_handle->len = zend_stream_read(file_handle, *buf, size);
|
||||
} else {
|
||||
|
@ -76,6 +76,9 @@ class userstream {
|
||||
function stream_stat() {
|
||||
return array('size' => strlen($this->data));
|
||||
}
|
||||
function stream_set_option($option, $arg1, $arg2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
stream_wrapper_register("cookietest", "userstream");
|
||||
|
@ -96,6 +96,9 @@ class mystream
|
||||
}
|
||||
}
|
||||
|
||||
function stream_set_option($option, $arg1, $arg2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stream_wrapper_register("test", "mystream")) {
|
||||
|
@ -1568,6 +1568,8 @@ PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *h
|
||||
handle->handle.stream.closer = php_zend_stream_closer;
|
||||
/* suppress warning if this stream is not explicitly closed */
|
||||
php_stream_auto_cleanup(stream);
|
||||
/* Disable buffering to avoid double buffering between PHP and Zend streams. */
|
||||
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER, PHP_STREAM_BUFFER_NONE, NULL);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ final class StreamWrapper
|
||||
public function stream_close() : bool { return \fclose($this->stream); }
|
||||
public function stream_eof() : bool { return \feof($this->stream); }
|
||||
public function stream_stat() { return \fstat($this->stream); }
|
||||
public function stream_set_option($option, $arg1, $arg2) { return false; }
|
||||
|
||||
private $stream = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user