summaryrefslogtreecommitdiff
path: root/main/streams
diff options
context:
space:
mode:
Diffstat (limited to 'main/streams')
-rw-r--r--main/streams/cast.c6
-rw-r--r--main/streams/filter.c6
-rw-r--r--main/streams/glob_wrapper.c2
-rw-r--r--main/streams/memory.c14
-rw-r--r--main/streams/mmap.c2
-rw-r--r--main/streams/php_stream_context.h4
-rw-r--r--main/streams/php_stream_filter_api.h2
-rw-r--r--main/streams/php_stream_glob_wrapper.h2
-rw-r--r--main/streams/php_stream_mmap.h2
-rw-r--r--main/streams/php_stream_plain_wrapper.h2
-rw-r--r--main/streams/php_stream_transport.h2
-rw-r--r--main/streams/php_stream_userspace.h2
-rw-r--r--main/streams/php_streams_int.h2
-rw-r--r--main/streams/plain_wrapper.c44
-rw-r--r--main/streams/streams.c56
-rw-r--r--main/streams/transports.c10
-rw-r--r--main/streams/userspace.c196
-rw-r--r--main/streams/xp_socket.c22
18 files changed, 151 insertions, 225 deletions
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 73421a7588..9e689e9d6c 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -295,7 +293,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
}
if (php_stream_is_filtered(stream)) {
- php_error_docref(NULL, E_WARNING, "cannot cast a filtered stream on this system");
+ php_error_docref(NULL, E_WARNING, "Cannot cast a filtered stream on this system");
return FAILURE;
} else if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS) {
goto exit_success;
@@ -310,7 +308,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
"select()able descriptor"
};
- php_error_docref(NULL, E_WARNING, "cannot represent a stream of type %s as a %s", stream->ops->label, cast_names[castas]);
+ php_error_docref(NULL, E_WARNING, "Cannot represent a stream of type %s as a %s", stream->ops->label, cast_names[castas]);
}
return FAILURE;
diff --git a/main/streams/filter.c b/main/streams/filter.c
index f536b92a02..e14925c1d7 100644
--- a/main/streams/filter.c
+++ b/main/streams/filter.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -255,9 +253,9 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
if (filter == NULL) {
/* TODO: these need correct docrefs */
if (factory == NULL)
- php_error_docref(NULL, E_WARNING, "unable to locate filter \"%s\"", filtername);
+ php_error_docref(NULL, E_WARNING, "Unable to locate filter \"%s\"", filtername);
else
- php_error_docref(NULL, E_WARNING, "unable to create or locate filter \"%s\"", filtername);
+ php_error_docref(NULL, E_WARNING, "Unable to create or locate filter \"%s\"", filtername);
}
return filter;
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 0e72558a2a..212d905e16 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/memory.c b/main/streams/memory.c
index 4b92fc2ffd..0def3b1a3d 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -256,9 +254,9 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu
ms->fsize = newsize;
return PHP_STREAM_OPTION_RETURN_OK;
}
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
/* }}} */
@@ -317,7 +315,7 @@ PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC)
/* {{{ */
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC)
+PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_memory_data *ms;
@@ -327,7 +325,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
/* use the buffer directly */
- ms->data = buf;
+ ms->data = (char *) buf;
ms->fsize = length;
} else {
if (length) {
@@ -600,7 +598,7 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
/* }}} */
/* {{{ _php_stream_temp_open */
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC)
+PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_temp_data *ts;
@@ -621,7 +619,7 @@ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char
/* }}} */
PHPAPI const php_stream_ops php_stream_rfc2397_ops = {
- php_stream_temp_write, php_stream_temp_read,
+ NULL, php_stream_temp_read,
php_stream_temp_close, php_stream_temp_flush,
"RFC2397",
php_stream_temp_seek,
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 63bae87505..c99c63f065 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
index c477dda4ac..29c9ae28a6 100644
--- a/main/streams/php_stream_context.h
+++ b/main/streams/php_stream_context.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -102,7 +100,7 @@ END_EXTERN_C()
(context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)
-#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \
+#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && ((context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS)) { \
(context)->notifier->progress += (dsofar); \
(context)->notifier->progress_max += (dmax); \
php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
index 4d5760e2cf..9df312152a 100644
--- a/main/streams/php_stream_filter_api.h
+++ b/main/streams/php_stream_filter_api.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h
index 644e5ab7e4..f4c8e05b7e 100644
--- a/main/streams/php_stream_glob_wrapper.h
+++ b/main/streams/php_stream_glob_wrapper.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index 40288cc27f..3fda788f19 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h
index 4af8b86cdd..44910bf320 100644
--- a/main/streams/php_stream_plain_wrapper.h
+++ b/main/streams/php_stream_plain_wrapper.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index f49d9c787d..69d2b9a774 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h
index 389d591921..4171a0d953 100644
--- a/main/streams/php_stream_userspace.h
+++ b/main/streams/php_stream_userspace.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
index 1bc6fdc89c..ab00549a6e 100644
--- a/main/streams/php_streams_int.h
+++ b/main/streams/php_streams_int.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 8bd20969f9..e3eda978d8 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -135,11 +133,11 @@ typedef struct {
int lock_flag; /* stores the lock state */
zend_string *temp_name; /* if non-null, this is the path to a temporary file that
* is to be deleted when the stream is closed */
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
char last_op;
#endif
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
char *last_mapped_addr;
size_t last_mapped_len;
#endif
@@ -233,7 +231,7 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char
}
close(fd);
- php_error_docref(NULL, E_WARNING, "unable to allocate stream");
+ php_error_docref(NULL, E_WARNING, "Unable to allocate stream");
return NULL;
}
@@ -259,6 +257,11 @@ static void detect_is_seekable(php_stdio_stream_data *self) {
self->is_seekable = !(file_type == FILE_TYPE_PIPE || file_type == FILE_TYPE_CHAR);
self->is_pipe = file_type == FILE_TYPE_PIPE;
+
+ /* Additional check needed to distinguish between pipes and sockets. */
+ if (self->is_pipe && !GetNamedPipeInfo((HANDLE) handle, NULL, NULL, NULL, NULL)) {
+ self->is_pipe = 0;
+ }
}
#endif
}
@@ -355,12 +358,14 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
/* TODO: Should this be treated as a proper error or not? */
return bytes_written;
}
- php_error_docref(NULL, E_NOTICE, "write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ if (!(stream->flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS)) {
+ php_error_docref(NULL, E_NOTICE, "Write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ }
}
return bytes_written;
} else {
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
if (data->is_seekable && data->last_op == 'r') {
zend_fseek(data->file, 0, SEEK_CUR);
}
@@ -394,7 +399,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
if (!PeekNamedPipe(ph, NULL, 0, NULL, &avail_read, NULL)) {
break;
}
- /* If there's nothing to read, wait in 10ms periods. */
+ /* If there's nothing to read, wait in 10us periods. */
if (0 == avail_read) {
usleep(10);
}
@@ -423,7 +428,9 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
} else if (errno == EINTR) {
/* TODO: Should this be treated as a proper error or not? */
} else {
- php_error_docref(NULL, E_NOTICE, "read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ if (!(stream->flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS)) {
+ php_error_docref(NULL, E_NOTICE, "Read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ }
/* TODO: Remove this special-case? */
if (errno != EBADF) {
@@ -435,7 +442,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
}
} else {
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
if (data->is_seekable && data->last_op == 'w')
zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
@@ -455,7 +462,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
assert(data != NULL);
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
if (data->last_mapped_addr) {
munmap(data->last_mapped_addr, data->last_mapped_len);
data->last_mapped_addr = NULL;
@@ -477,7 +484,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
errno = 0;
ret = pclose(data->file);
-#if HAVE_SYS_WAIT_H
+#ifdef HAVE_SYS_WAIT_H
if (WIFEXITED(ret)) {
ret = WEXITSTATUS(ret);
}
@@ -538,7 +545,7 @@ static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, ze
assert(data != NULL);
if (!data->is_seekable) {
- php_error_docref(NULL, E_WARNING, "cannot seek on this stream");
+ php_error_docref(NULL, E_WARNING, "Cannot seek on this stream");
return -1;
}
@@ -706,7 +713,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
break;
case PHP_STREAM_OPTION_MMAP_API:
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
{
php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam;
int prot, flags;
@@ -901,7 +908,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
return PHP_STREAM_OPTION_RETURN_ERR;
}
-#if defined(_WIN64)
+#ifdef _WIN64
sz.QuadPart = new_size;
#else
sz.HighPart = 0;
@@ -922,6 +929,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
#endif
}
}
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
#ifdef PHP_WIN32
case PHP_STREAM_OPTION_PIPE_BLOCKING:
@@ -1243,7 +1251,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
if (php_copy_file(url_from, url_to) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
success = 1;
-# if !defined(TSRM_WIN32)
+# ifndef TSRM_WIN32
/*
* Try to set user and permission info on the target.
* If we're not root, then some of these may fail.
@@ -1310,7 +1318,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
if (!recursive) {
ret = php_mkdir(dir, mode);
} else {
- /* we look for directory separator from the end of string, thus hopefuly reducing our work load */
+ /* we look for directory separator from the end of string, thus hopefully reducing our work load */
char *e;
zend_stat_t sb;
size_t dir_len = strlen(dir), offset = 0;
@@ -1481,7 +1489,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
ret = VCWD_CHMOD(url, mode);
break;
default:
- php_error_docref1(NULL, url, E_WARNING, "Unknown option %d for stream_metadata", option);
+ zend_value_error("Unknown option %d for stream_metadata", option);
return 0;
}
if (ret == -1) {
diff --git a/main/streams/streams.c b/main/streams/streams.c
index c1ecf34623..e5e90e0f4d 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -26,7 +24,7 @@
#include "php_network.h"
#include "php_open_temporary_file.h"
#include "ext/standard/file.h"
-#include "ext/standard/basic_functions.h" /* for BG(mmap_file) (not strictly required) */
+#include "ext/standard/basic_functions.h" /* for BG(CurrentStatFile) */
#include "ext/standard/php_string.h" /* for php_memnstr, used by php_stream_get_record() */
#include <stddef.h>
#include <fcntl.h>
@@ -247,7 +245,7 @@ PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int
vspprintf(&buffer, 0, fmt, args);
va_end(args);
- if (options & REPORT_ERRORS || wrapper == NULL) {
+ if ((options & REPORT_ERRORS) || wrapper == NULL) {
php_error_docref(NULL, E_WARNING, "%s", buffer);
efree(buffer);
} else {
@@ -706,7 +704,7 @@ PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t size)
break;
}
- if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) {
+ if (!stream->readfilters.head && ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) || stream->chunk_size == 1)) {
toread = stream->ops->read(stream, buf, size);
if (toread < 0) {
/* Report an error if the read failed and we did not read any data
@@ -1121,7 +1119,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con
/* Writes a buffer directly to a stream, using multiple of the chunk size */
static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, size_t count)
{
- ssize_t didwrite = 0, justwrote;
+ ssize_t didwrite = 0;
/* if we have a seekable stream we need to ensure that data is written at the
* current stream->position. This means invalidating the read buffer and then
@@ -1132,13 +1130,8 @@ static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, siz
stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position);
}
-
while (count > 0) {
- size_t towrite = count;
- if (towrite > stream->chunk_size)
- towrite = stream->chunk_size;
-
- justwrote = stream->ops->write(stream, buf, towrite);
+ ssize_t justwrote = stream->ops->write(stream, buf, count);
if (justwrote <= 0) {
/* If we already successfully wrote some bytes and a write error occurred
* later, report the successfully written bytes. */
@@ -1374,7 +1367,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
return 0;
}
- php_error_docref(NULL, E_WARNING, "stream does not support seeking");
+ php_error_docref(NULL, E_WARNING, "Stream does not support seeking");
return -1;
}
@@ -1882,7 +1875,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
if (localhost == 0 && path[n+3] != '\0' && path[n+3] != '/') {
#endif
if (options & REPORT_ERRORS) {
- php_error_docref(NULL, E_WARNING, "remote host file access not supported, %s", path);
+ php_error_docref(NULL, E_WARNING, "Remote host file access not supported, %s", path);
}
return NULL;
}
@@ -1949,8 +1942,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
}
/* }}} */
-/* {{{ _php_stream_mkdir
- */
+/* {{{ _php_stream_mkdir */
PHPAPI int _php_stream_mkdir(const char *path, int mode, int options, php_stream_context *context)
{
php_stream_wrapper *wrapper = NULL;
@@ -1964,8 +1956,7 @@ PHPAPI int _php_stream_mkdir(const char *path, int mode, int options, php_stream
}
/* }}} */
-/* {{{ _php_stream_rmdir
- */
+/* {{{ _php_stream_rmdir */
PHPAPI int _php_stream_rmdir(const char *path, int options, php_stream_context *context)
{
php_stream_wrapper *wrapper = NULL;
@@ -2048,7 +2039,7 @@ PHPAPI php_stream *_php_stream_opendir(const char *path, int options,
if (wrapper && wrapper->wops->dir_opener) {
stream = wrapper->wops->dir_opener(wrapper,
- path_to_open, "r", options ^ REPORT_ERRORS, NULL,
+ path_to_open, "r", options & ~REPORT_ERRORS, NULL,
context STREAMS_REL_CC);
if (stream) {
@@ -2056,10 +2047,10 @@ PHPAPI php_stream *_php_stream_opendir(const char *path, int options,
stream->flags |= PHP_STREAM_FLAG_NO_BUFFER | PHP_STREAM_FLAG_IS_DIR;
}
} else if (wrapper) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS, "not implemented");
+ php_stream_wrapper_log_error(wrapper, options & ~REPORT_ERRORS, "not implemented");
}
if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open dir");
+ php_stream_display_wrapper_errors(wrapper, path, "Failed to open directory");
}
php_stream_tidy_wrapper_error_log(wrapper);
@@ -2095,7 +2086,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (!path || !*path) {
- php_error_docref(NULL, E_WARNING, "Filename cannot be empty");
+ zend_value_error("Path cannot be empty");
return NULL;
}
@@ -2115,7 +2106,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
path_to_open = path;
wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options);
- if (options & STREAM_USE_URL && (!wrapper || !wrapper->is_url)) {
+ if ((options & STREAM_USE_URL) && (!wrapper || !wrapper->is_url)) {
php_error_docref(NULL, E_WARNING, "This function may only be used against URLs");
if (resolved_path) {
zend_string_release_ex(resolved_path, 0);
@@ -2125,18 +2116,18 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
if (wrapper) {
if (!wrapper->wops->stream_opener) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS,
+ php_stream_wrapper_log_error(wrapper, options & ~REPORT_ERRORS,
"wrapper does not support stream open");
} else {
stream = wrapper->wops->stream_opener(wrapper,
- path_to_open, mode, options ^ REPORT_ERRORS,
+ path_to_open, mode, options & ~REPORT_ERRORS,
opened_path, context STREAMS_REL_CC);
}
/* if the caller asked for a persistent stream but the wrapper did not
* return one, force an error here */
if (stream && (options & STREAM_OPEN_PERSISTENT) && !stream->is_persistent) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS,
+ php_stream_wrapper_log_error(wrapper, options & ~REPORT_ERRORS,
"wrapper does not support persistent streams");
php_stream_close(stream);
stream = NULL;
@@ -2193,7 +2184,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
tmp);
efree(tmp);
- options ^= REPORT_ERRORS;
+ options &= ~REPORT_ERRORS;
}
}
}
@@ -2208,7 +2199,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open stream");
+ php_stream_display_wrapper_errors(wrapper, path, "Failed to open stream");
if (opened_path && *opened_path) {
zend_string_release_ex(*opened_path, 0);
*opened_path = NULL;
@@ -2321,24 +2312,21 @@ PHPAPI int php_stream_context_set_option(php_stream_context *context,
}
/* }}} */
-/* {{{ php_stream_dirent_alphasort
- */
+/* {{{ php_stream_dirent_alphasort */
PHPAPI int php_stream_dirent_alphasort(const zend_string **a, const zend_string **b)
{
return strcoll(ZSTR_VAL(*a), ZSTR_VAL(*b));
}
/* }}} */
-/* {{{ php_stream_dirent_alphasortr
- */
+/* {{{ php_stream_dirent_alphasortr */
PHPAPI int php_stream_dirent_alphasortr(const zend_string **a, const zend_string **b)
{
return strcoll(ZSTR_VAL(*b), ZSTR_VAL(*a));
}
/* }}} */
-/* {{{ php_stream_scandir
- */
+/* {{{ php_stream_scandir */
PHPAPI int _php_stream_scandir(const char *dirname, zend_string **namelist[], int flags, php_stream_context *context,
int (*compare) (const zend_string **a, const zend_string **b))
{
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 74fbef58d8..fcc3f29330 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -359,7 +357,7 @@ PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_cr
return param.outputs.returncode;
}
- php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ php_error_docref("streams.crypto", E_WARNING, "This stream does not support SSL/crypto");
return ret;
}
@@ -379,7 +377,7 @@ PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate)
return param.outputs.returncode;
}
- php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ php_error_docref("streams.crypto", E_WARNING, "This stream does not support SSL/crypto");
return ret;
}
@@ -401,7 +399,7 @@ PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t bufle
}
if (stream->readfilters.head) {
- php_error_docref(NULL, E_WARNING, "cannot peek or fetch OOB data from a filtered stream");
+ php_error_docref(NULL, E_WARNING, "Cannot peek or fetch OOB data from a filtered stream");
return -1;
}
@@ -471,7 +469,7 @@ PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t b
oob = (flags & STREAM_OOB) == STREAM_OOB;
if ((oob || addr) && stream->writefilters.head) {
- php_error_docref(NULL, E_WARNING, "cannot write OOB data, or data to a targeted address on a filtered stream");
+ php_error_docref(NULL, E_WARNING, "Cannot write OOB data, or data to a targeted address on a filtered stream");
return -1;
}
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index cf8f59b756..0e9059a99e 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -38,7 +36,6 @@ static int le_protocols;
struct php_user_stream_wrapper {
char * protoname;
- char * classname;
zend_class_entry *ce;
php_stream_wrapper wrapper;
};
@@ -73,7 +70,6 @@ static void stream_wrapper_dtor(zend_resource *rsrc)
struct php_user_stream_wrapper * uwrap = (struct php_user_stream_wrapper*)rsrc->ptr;
efree(uwrap->protoname);
- efree(uwrap->classname);
efree(uwrap);
}
@@ -300,29 +296,8 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php
}
if (uwrap->ce->constructor) {
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
- zval retval;
-
- fci.size = sizeof(fci);
- ZVAL_UNDEF(&fci.function_name);
- fci.object = Z_OBJ_P(object);
- fci.retval = &retval;
- fci.param_count = 0;
- fci.params = NULL;
- fci.no_separation = 1;
-
- fcc.function_handler = uwrap->ce->constructor;
- fcc.called_scope = Z_OBJCE_P(object);
- fcc.object = Z_OBJ_P(object);
-
- if (zend_call_function(&fci, &fcc) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Could not execute %s::%s()", ZSTR_VAL(uwrap->ce->name), ZSTR_VAL(uwrap->ce->constructor->common.function_name));
- zval_ptr_dtor(object);
- ZVAL_UNDEF(object);
- } else {
- zval_ptr_dtor(&retval);
- }
+ zend_call_known_instance_method_with_0_params(
+ uwrap->ce->constructor, Z_OBJ_P(object), NULL);
}
}
@@ -375,12 +350,11 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
ZVAL_STRING(&zfuncname, USERSTREAM_OPEN);
zend_try {
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&zfuncname,
&zretval,
- 4, args,
- 0, NULL );
+ 4, args);
} zend_catch {
FG(user_stream_current_filename) = NULL;
zend_bailout();
@@ -399,7 +373,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options, "\"%s::" USERSTREAM_OPEN "\" call failed",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
/* destroy everything else */
@@ -454,12 +428,11 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
ZVAL_STRING(&zfuncname, USERSTREAM_DIR_OPEN);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && Z_TYPE(zretval) != IS_UNDEF && zval_is_true(&zretval)) {
/* the stream is now open! */
@@ -469,7 +442,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options, "\"%s::" USERSTREAM_DIR_OPEN "\" call failed",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
/* destroy everything else */
@@ -490,42 +463,38 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
}
-/* {{{ proto bool stream_wrapper_register(string protocol, string classname[, int flags])
- Registers a custom URL protocol handler class */
+/* {{{ Registers a custom URL protocol handler class */
PHP_FUNCTION(stream_wrapper_register)
{
- zend_string *protocol, *classname;
- struct php_user_stream_wrapper * uwrap;
+ zend_string *protocol;
+ struct php_user_stream_wrapper *uwrap;
+ zend_class_entry *ce = NULL;
zend_resource *rsrc;
zend_long flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &protocol, &classname, &flags) == FAILURE) {
- RETURN_FALSE;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "SC|l", &protocol, &ce, &flags) == FAILURE) {
+ RETURN_THROWS();
}
uwrap = (struct php_user_stream_wrapper *)ecalloc(1, sizeof(*uwrap));
+ uwrap->ce = ce;
uwrap->protoname = estrndup(ZSTR_VAL(protocol), ZSTR_LEN(protocol));
- uwrap->classname = estrndup(ZSTR_VAL(classname), ZSTR_LEN(classname));
uwrap->wrapper.wops = &user_stream_wops;
uwrap->wrapper.abstract = uwrap;
uwrap->wrapper.is_url = ((flags & PHP_STREAM_IS_URL) != 0);
rsrc = zend_register_resource(uwrap, le_protocols);
- if ((uwrap->ce = zend_lookup_class(classname)) != NULL) {
- if (php_register_url_stream_wrapper_volatile(protocol, &uwrap->wrapper) == SUCCESS) {
- RETURN_TRUE;
- } else {
- /* We failed. But why? */
- if (zend_hash_exists(php_stream_get_url_stream_wrappers_hash(), protocol)) {
- php_error_docref(NULL, E_WARNING, "Protocol %s:// is already defined.", ZSTR_VAL(protocol));
- } else {
- /* Hash doesn't exist so it must have been an invalid protocol scheme */
- php_error_docref(NULL, E_WARNING, "Invalid protocol scheme specified. Unable to register wrapper class %s to %s://", ZSTR_VAL(classname), ZSTR_VAL(protocol));
- }
- }
+ if (php_register_url_stream_wrapper_volatile(protocol, &uwrap->wrapper) == SUCCESS) {
+ RETURN_TRUE;
+ }
+
+ /* We failed. But why? */
+ if (zend_hash_exists(php_stream_get_url_stream_wrappers_hash(), protocol)) {
+ php_error_docref(NULL, E_WARNING, "Protocol %s:// is already defined.", ZSTR_VAL(protocol));
} else {
- php_error_docref(NULL, E_WARNING, "class '%s' is undefined", ZSTR_VAL(classname));
+ /* Hash doesn't exist so it must have been an invalid protocol scheme */
+ php_error_docref(NULL, E_WARNING, "Invalid protocol scheme specified. Unable to register wrapper class %s to %s://", ZSTR_VAL(uwrap->ce->name), ZSTR_VAL(protocol));
}
zend_list_delete(rsrc);
@@ -533,14 +502,13 @@ PHP_FUNCTION(stream_wrapper_register)
}
/* }}} */
-/* {{{ proto bool stream_wrapper_unregister(string protocol)
- Unregister a wrapper for the life of the current request. */
+/* {{{ Unregister a wrapper for the life of the current request. */
PHP_FUNCTION(stream_wrapper_unregister)
{
zend_string *protocol;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
if (php_unregister_url_stream_wrapper_volatile(protocol) == FAILURE) {
@@ -553,8 +521,7 @@ PHP_FUNCTION(stream_wrapper_unregister)
}
/* }}} */
-/* {{{ proto bool stream_wrapper_restore(string protocol)
- Restore the original protocol handler, overriding if necessary */
+/* {{{ Restore the original protocol handler, overriding if necessary */
PHP_FUNCTION(stream_wrapper_restore)
{
zend_string *protocol;
@@ -562,7 +529,7 @@ PHP_FUNCTION(stream_wrapper_restore)
HashTable *global_wrapper_hash, *wrapper_hash;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
global_wrapper_hash = php_stream_get_url_stream_wrappers_hash_global();
@@ -604,12 +571,11 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_
ZVAL_STRINGL(&args[0], (char*)buf, count);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args,
- 0, NULL);
+ 1, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&func_name);
@@ -626,14 +592,14 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_
}
} else {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_WRITE " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
didwrite = -1;
}
/* don't allow strange buffer overruns due to bogus return */
if (didwrite > 0 && didwrite > count) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_WRITE " wrote " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " written, " ZEND_LONG_FMT " max)",
- us->wrapper->classname,
+ ZSTR_VAL(us->wrapper->ce->name),
(zend_long)(didwrite - count), (zend_long)didwrite, (zend_long)count);
didwrite = count;
}
@@ -658,12 +624,11 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
ZVAL_LONG(&args[0], count);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args,
- 0, NULL);
+ 1, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&func_name);
@@ -674,7 +639,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
return -1;
}
@@ -690,7 +655,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
if (didread > 0) {
if (didread > count) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " - read " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " read, " ZEND_LONG_FMT " max) - excess data will be lost",
- us->wrapper->classname, (zend_long)(didread - count), (zend_long)didread, (zend_long)count);
+ ZSTR_VAL(us->wrapper->ce->name), (zend_long)(didread - count), (zend_long)didread, (zend_long)count);
didread = count;
}
memcpy(buf, Z_STRVAL(retval), didread);
@@ -719,7 +684,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
} else if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
stream->eof = 1;
}
@@ -799,12 +764,11 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when
ZVAL_LONG(&args[0], offset);
ZVAL_LONG(&args[1], whence);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 2, args,
- 0, NULL);
+ 2, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
@@ -844,7 +808,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when
*newoffs = Z_LVAL(retval);
ret = 0;
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", us->wrapper->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", ZSTR_VAL(us->wrapper->ce->name));
ret = -1;
} else {
ret = -1;
@@ -916,7 +880,7 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb)
} else {
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_STAT " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
}
@@ -945,7 +909,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ret = PHP_STREAM_OPTION_RETURN_ERR;
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
zval_ptr_dtor(&retval);
zval_ptr_dtor(&func_name);
@@ -972,11 +936,11 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
/* TODO wouldblock */
ZVAL_STRINGL(&func_name, USERSTREAM_LOCK, sizeof(USERSTREAM_LOCK)-1);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args, 0, NULL);
+ 1, args);
if (call_result == SUCCESS && (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE)) {
ret = (Z_TYPE(retval) == IS_FALSE);
@@ -986,7 +950,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ret = PHP_STREAM_OPTION_RETURN_OK;
} else {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_LOCK " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
ret = PHP_STREAM_OPTION_RETURN_ERR;
}
}
@@ -1003,7 +967,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
case PHP_STREAM_TRUNCATE_SUPPORTED:
if (zend_is_callable_ex(&func_name,
Z_ISUNDEF(us->object)? NULL : Z_OBJ(us->object),
- IS_CALLABLE_CHECK_SILENT, NULL, NULL, NULL))
+ 0, NULL, NULL, NULL))
ret = PHP_STREAM_OPTION_RETURN_OK;
else
ret = PHP_STREAM_OPTION_RETURN_ERR;
@@ -1013,11 +977,11 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ptrdiff_t new_size = *(ptrdiff_t*) ptrparam;
if (new_size >= 0 && new_size <= (ptrdiff_t)LONG_MAX) {
ZVAL_LONG(&args[0], (zend_long)new_size);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args, 0, NULL);
+ 1, args);
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) {
ret = (Z_TYPE(retval) == IS_TRUE) ? PHP_STREAM_OPTION_RETURN_OK :
@@ -1025,12 +989,12 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
} else {
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_TRUNCATE " did not return a boolean!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
} else {
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_TRUNCATE " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[0]);
@@ -1077,15 +1041,15 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
break;
}
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 3, args, 0, NULL);
+ 3, args);
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
ret = PHP_STREAM_OPTION_RETURN_ERR;
} else if (zend_is_true(&retval)) {
ret = PHP_STREAM_OPTION_RETURN_OK;
@@ -1127,17 +1091,16 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
ZVAL_STRING(&zfuncname, USERSTREAM_UNLINK);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 1, args,
- 0, NULL );
+ 1, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_UNLINK " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_UNLINK " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1172,17 +1135,16 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
ZVAL_STRING(&zfuncname, USERSTREAM_RENAME);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RENAME " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RENAME " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1219,17 +1181,16 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int
ZVAL_STRING(&zfuncname, USERSTREAM_MKDIR);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 3, args,
- 0, NULL );
+ 3, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_MKDIR " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_MKDIR " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1266,17 +1227,16 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url,
ZVAL_STRING(&zfuncname, USERSTREAM_RMDIR);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RMDIR " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RMDIR " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1337,17 +1297,16 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
ZVAL_STRING(&zfuncname, USERSTREAM_METADATA);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 3, args,
- 0, NULL );
+ 3, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = Z_TYPE(zretval) == IS_TRUE;
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_METADATA " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_METADATA " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1385,12 +1344,11 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
ZVAL_STRING(&zfuncname, USERSTREAM_STATURL);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && Z_TYPE(zretval) == IS_ARRAY) {
/* We got the info we needed */
@@ -1399,7 +1357,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
} else {
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_STATURL " is not implemented!",
- uwrap->classname);
+ ZSTR_VAL(uwrap->ce->name));
}
}
@@ -1443,7 +1401,7 @@ static ssize_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t co
didread = sizeof(php_stream_dirent);
} else if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_DIR_READ " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
zval_ptr_dtor(&retval);
@@ -1520,16 +1478,16 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
break;
}
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args, 0, NULL);
+ 1, args);
do {
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_CAST " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
break;
}
if (!zend_is_true(&retval)) {
@@ -1538,12 +1496,12 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
php_stream_from_zval_no_verify(intstream, &retval);
if (!intstream) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_CAST " must return a stream resource",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
break;
}
if (intstream == stream) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_CAST " must not return itself",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
intstream = NULL;
break;
}
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 46b23b63ad..a369bf5ff2 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -25,7 +23,7 @@
# undef AF_UNIX
#endif
-#if defined(AF_UNIX)
+#ifdef AF_UNIX
#include <sys/un.h>
#endif
@@ -105,10 +103,13 @@ retry:
}
}
- estr = php_socket_strerror(err, NULL, 0);
- php_error_docref(NULL, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
+ if (!(stream->flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS)) {
+ estr = php_socket_strerror(err, NULL, 0);
+ php_error_docref(NULL, E_NOTICE,
+ "Send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
(zend_long)count, err, estr);
- efree(estr);
+ efree(estr);
+ }
}
if (didwrite > 0) {
@@ -239,7 +240,7 @@ static int php_sockop_flush(php_stream *stream)
static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb)
{
-#if ZEND_WIN32
+#ifdef ZEND_WIN32
return 0;
#else
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
@@ -451,12 +452,11 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
#endif
default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
+ break;
}
-
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
static int php_sockop_cast(php_stream *stream, int castas, void **ret)