diff --git a/ext/curl/tests/check_win_config.phpt b/ext/curl/tests/check_win_config.phpt index 405a1b9072098..7f656ef9ea753 100644 --- a/ext/curl/tests/check_win_config.phpt +++ b/ext/curl/tests/check_win_config.phpt @@ -45,7 +45,7 @@ GSSAPI => No KERBEROS5 => Yes UNIX_SOCKETS => No PSL => No -Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp +Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp Host => %s-pc-win32 SSL Version => OpenSSL/%s ZLib Version => %s diff --git a/ext/standard/file.c b/ext/standard/file.c index 5a1b3b955cb06..a14e93652846d 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -881,7 +881,7 @@ PHP_NAMED_FUNCTION(php_if_fopen) Z_PARAM_STRING(mode, mode_len) Z_PARAM_OPTIONAL Z_PARAM_BOOL(use_include_path) - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_EX(zcontext, 1, 0) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); context = php_stream_context_from_zval(zcontext, 0); @@ -1344,7 +1344,7 @@ PHP_FUNCTION(mkdir) Z_PARAM_OPTIONAL Z_PARAM_LONG(mode) Z_PARAM_BOOL(recursive) - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_EX(zcontext, 1, 0) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); context = php_stream_context_from_zval(zcontext, 0); @@ -1365,7 +1365,7 @@ PHP_FUNCTION(rmdir) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_PATH(dir, dir_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_EX(zcontext, 1, 0) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); context = php_stream_context_from_zval(zcontext, 0); @@ -1467,7 +1467,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(zcontext) + Z_PARAM_RESOURCE_EX(zcontext, 1, 0) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0); @@ -1506,7 +1506,7 @@ PHP_FUNCTION(unlink) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_PATH(filename, filename_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_EX(zcontext, 1, 0) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); context = php_stream_context_from_zval(zcontext, 0); @@ -1663,7 +1663,7 @@ PHP_FUNCTION(copy) Z_PARAM_PATH(source, source_len) Z_PARAM_PATH(target, target_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_EX(zcontext, 1, 0) ZEND_PARSE_PARAMETERS_END(); if (php_check_open_basedir(source)) { diff --git a/ext/standard/tests/file/bug74719.phpt b/ext/standard/tests/file/bug74719.phpt new file mode 100644 index 0000000000000..7cf90487e24f5 --- /dev/null +++ b/ext/standard/tests/file/bug74719.phpt @@ -0,0 +1,61 @@ +--TEST-- +Bug #74719 Allow NULL as context, testing fopen, rename, unlink, mkdir and rmdir +--CREDITS-- +Alexander Holman +--FILE-- + +===DONE=== +--EXPECT-- +ok +ok +ok +ok +ok +===DONE=== diff --git a/ext/standard/tests/file/fopen_variation4.phpt b/ext/standard/tests/file/fopen_variation4.phpt index 38f5fefe62b51..4bd5b2a446e32 100644 --- a/ext/standard/tests/file/fopen_variation4.phpt +++ b/ext/standard/tests/file/fopen_variation4.phpt @@ -182,12 +182,10 @@ Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d) bool(false) --uppercase NULL-- -Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d) -bool(false) +ok --lowercase null-- -Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d) -bool(false) +ok --lowercase true-- Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d) @@ -238,12 +236,10 @@ Error: 2 - fopen() expects parameter 4 to be resource, object given, %s(%d) bool(false) --undefined var-- -Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d) -bool(false) +ok --unset var-- -Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d) -bool(false) +ok --file resource-- Error: 2 - fopen(): supplied resource is not a valid Stream-Context resource, %s(%d) diff --git a/ext/standard/tests/file/mkdir_variation4.phpt b/ext/standard/tests/file/mkdir_variation4.phpt index deb6ff4a450c9..a866f8d16f691 100644 --- a/ext/standard/tests/file/mkdir_variation4.phpt +++ b/ext/standard/tests/file/mkdir_variation4.phpt @@ -167,10 +167,10 @@ Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d) Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d) --uppercase NULL-- -Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d) +Directory created --lowercase null-- -Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d) +Directory created --lowercase true-- Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d) @@ -209,10 +209,10 @@ Error: 2 - mkdir() expects parameter 4 to be resource, object given, %s(%d) Error: 2 - mkdir() expects parameter 4 to be resource, object given, %s(%d) --undefined var-- -Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d) +Directory created --unset var-- -Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d) +Directory created --file resource-- Error: 2 - mkdir(): supplied resource is not a valid Stream-Context resource, %s(%d) diff --git a/ext/standard/tests/file/rename_variation10.phpt b/ext/standard/tests/file/rename_variation10.phpt index 42909ee484d06..5c81757ed80cf 100644 --- a/ext/standard/tests/file/rename_variation10.phpt +++ b/ext/standard/tests/file/rename_variation10.phpt @@ -184,12 +184,10 @@ Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d) bool(false) --uppercase NULL-- -Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d) -bool(false) +bool(true) --lowercase null-- -Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d) -bool(false) +bool(true) --lowercase true-- Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d) @@ -240,12 +238,10 @@ Error: 2 - rename() expects parameter 3 to be resource, object given, %s(%d) bool(false) --undefined var-- -Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d) -bool(false) +bool(true) --unset var-- -Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d) -bool(false) +bool(true) --file resource-- Error: 2 - rename(): supplied resource is not a valid Stream-Context resource, %s(%d) diff --git a/ext/standard/tests/file/rmdir_variation2.phpt b/ext/standard/tests/file/rmdir_variation2.phpt index 7b4311c245537..6053018f42d74 100644 --- a/ext/standard/tests/file/rmdir_variation2.phpt +++ b/ext/standard/tests/file/rmdir_variation2.phpt @@ -175,12 +175,10 @@ Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d) bool(false) --uppercase NULL-- -Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --lowercase null-- -Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --lowercase true-- Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d) @@ -231,12 +229,10 @@ Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d) bool(false) --undefined var-- -Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --unset var-- -Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --0-- Error: 2 - rmdir(): supplied resource is not a valid Stream-Context resource, %s(%d) diff --git a/ext/standard/tests/file/unlink_error-win32-mb.phpt b/ext/standard/tests/file/unlink_error-win32-mb.phpt index 5111f34b76f7c..e96aa05b9c37a 100644 --- a/ext/standard/tests/file/unlink_error-win32-mb.phpt +++ b/ext/standard/tests/file/unlink_error-win32-mb.phpt @@ -45,7 +45,6 @@ var_dump( file_exists(false) ); // confirm file doesnt exist var_dump( unlink($filename, '') ); // $context as empty string var_dump( unlink($filename, false) ); // $context as boolean false -var_dump( unlink($filename, NULL) ); // $context as NULL echo "\n-- Testing unlink() on non-existent file --\n"; @@ -98,9 +97,6 @@ bool(false) Warning: unlink() expects parameter 2 to be resource, boolean given in %s on line %d bool(false) -Warning: unlink() expects parameter 2 to be resource, null given in %s on line %d -bool(false) - -- Testing unlink() on non-existent file -- Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d diff --git a/ext/standard/tests/file/unlink_error-win32.phpt b/ext/standard/tests/file/unlink_error-win32.phpt index e55f6ed5cd48d..8c73c353583f4 100644 --- a/ext/standard/tests/file/unlink_error-win32.phpt +++ b/ext/standard/tests/file/unlink_error-win32.phpt @@ -43,7 +43,6 @@ var_dump( file_exists(false) ); // confirm file doesnt exist var_dump( unlink($filename, '') ); // $context as empty string var_dump( unlink($filename, false) ); // $context as boolean false -var_dump( unlink($filename, NULL) ); // $context as NULL echo "\n-- Testing unlink() on non-existent file --\n"; @@ -95,9 +94,6 @@ bool(false) Warning: unlink() expects parameter 2 to be resource, boolean given in %s on line %d bool(false) -Warning: unlink() expects parameter 2 to be resource, null given in %s on line %d -bool(false) - -- Testing unlink() on non-existent file -- Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d diff --git a/ext/standard/tests/file/unlink_error.phpt b/ext/standard/tests/file/unlink_error.phpt index ae888bce4acb6..b1af8fd736202 100644 --- a/ext/standard/tests/file/unlink_error.phpt +++ b/ext/standard/tests/file/unlink_error.phpt @@ -43,7 +43,6 @@ var_dump( file_exists(false) ); // confirm file doesnt exist var_dump( unlink($filename, '') ); // $context as empty string var_dump( unlink($filename, false) ); // $context as boolean false -var_dump( unlink($filename, NULL) ); // $context as NULL echo "\n-- Testing unlink() on non-existent file --\n"; @@ -95,9 +94,6 @@ bool(false) Warning: unlink() expects parameter 2 to be resource, boolean given in %s on line %d bool(false) -Warning: unlink() expects parameter 2 to be resource, null given in %s on line %d -bool(false) - -- Testing unlink() on non-existent file -- Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d diff --git a/ext/standard/tests/file/unlink_variation7.phpt b/ext/standard/tests/file/unlink_variation7.phpt index 64a2607d5f5ce..f165e4e9c2d66 100644 --- a/ext/standard/tests/file/unlink_variation7.phpt +++ b/ext/standard/tests/file/unlink_variation7.phpt @@ -177,12 +177,10 @@ Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d) bool(false) --uppercase NULL-- -Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --lowercase null-- -Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --lowercase true-- Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d) @@ -233,12 +231,10 @@ Error: 2 - unlink() expects parameter 2 to be resource, object given, %s(%d) bool(false) --undefined var-- -Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --unset var-- -Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d) -bool(false) +bool(true) --file resource-- Error: 2 - unlink(): supplied resource is not a valid Stream-Context resource, %s(%d)