diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 799f1760ba5..16efa342221 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1517,6 +1517,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num #define Z_PARAM_RESOURCE(dest) \ Z_PARAM_RESOURCE_EX(dest, 0, 0) +#define Z_PARAM_RESOURCE_OR_NULL(dest) \ + Z_PARAM_RESOURCE_EX(dest, 1, 0) + /* old "s" */ #define Z_PARAM_STRING_EX2(dest, dest_len, check_null, deref, separate) \ Z_PARAM_PROLOGUE(deref, separate); \ diff --git a/ext/standard/file.c b/ext/standard/file.c index 5cde0ef9781..f6a75946d14 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -534,7 +534,7 @@ PHP_FUNCTION(file_get_contents) Z_PARAM_PATH(filename, filename_len) Z_PARAM_OPTIONAL Z_PARAM_BOOL(use_include_path) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) Z_PARAM_LONG(offset) Z_PARAM_LONG(maxlen) ZEND_PARSE_PARAMETERS_END(); @@ -593,7 +593,7 @@ PHP_FUNCTION(file_put_contents) Z_PARAM_ZVAL(data) Z_PARAM_OPTIONAL Z_PARAM_LONG(flags) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); if (Z_TYPE_P(data) == IS_RESOURCE) { @@ -738,7 +738,7 @@ PHP_FUNCTION(file) Z_PARAM_PATH(filename, filename_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(flags) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) { @@ -879,7 +879,7 @@ PHP_FUNCTION(fopen) Z_PARAM_STRING(mode, mode_len) Z_PARAM_OPTIONAL Z_PARAM_BOOL(use_include_path) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); @@ -1296,7 +1296,7 @@ PHP_FUNCTION(mkdir) Z_PARAM_OPTIONAL Z_PARAM_LONG(mode) Z_PARAM_BOOL(recursive) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); @@ -1317,7 +1317,7 @@ PHP_FUNCTION(rmdir) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_PATH(dir, dir_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); @@ -1342,7 +1342,7 @@ PHP_FUNCTION(readfile) Z_PARAM_PATH(filename, filename_len) Z_PARAM_OPTIONAL Z_PARAM_BOOL(use_include_path) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); @@ -1419,7 +1419,7 @@ PHP_FUNCTION(rename) Z_PARAM_PATH(old_name, old_name_len) Z_PARAM_PATH(new_name, new_name_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0); @@ -1458,7 +1458,7 @@ PHP_FUNCTION(unlink) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_PATH(filename, filename_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); @@ -1603,7 +1603,7 @@ PHP_FUNCTION(copy) Z_PARAM_PATH(source, source_len) Z_PARAM_PATH(target, target_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); if (php_check_open_basedir(source)) { diff --git a/ext/standard/url.c b/ext/standard/url.c index f2ef2c16d93..e3e04a9cd9e 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -672,7 +672,7 @@ PHP_FUNCTION(get_headers) Z_PARAM_PATH(url, url_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(format) - Z_PARAM_RESOURCE_EX(zcontext, 1, 0) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0);