used). (Anton Artamonov)
- Standard:
- . Fixed unzserialize(), to disable creation of unsupported data structures
+ . Fixed unserialize(), to disable creation of unsupported data structures
through manually crafted strings. (Dmitry)
. Fixed bug #75409 (accept EFAULT in addition to ENOSYS as indicator
that getrandom() is missing). (sarciszewski)
+ . Fixed bug #74719 (fopen() should accept NULL as context). (Alexander Holman)
- Testing:
. Implemented request #62055 (Make run-tests.php support --CGI-- sections).
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);
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);
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);
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);
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);
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)) {
--- /dev/null
+--TEST--
+Bug #74719 Allow NULL as context, testing fopen, rename, unlink, mkdir and rmdir
+--CREDITS--
+Alexander Holman <alexander@holman.org.uk>
+--FILE--
+<?php
+
+// fopen
+$tmpFile = __DIR__ . "/bug74719.tmp";
+$h = fopen($tmpFile, "w", false, NULL);
+if ($h !== false) {
+ echo "ok\n";
+ fclose($h);
+}
+
+$newTmpFile = __DIR__ . "/bug74719_renamed.tmp";
+if (rename($tmpFile, $newTmpFile, NULL)) {
+ echo "ok\n";
+}
+
+if (unlink($newTmpFile, NULL)) {
+ echo "ok\n";
+}
+
+$tmpDir = __DIR__ . "/bug74719_dir";
+
+if (mkdir($tmpDir, 0777, false, NULL)) {
+ echo "ok\n";
+}
+
+if (rmdir($tmpDir, NULL)) {
+ echo "ok\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+ok
+ok
+ok
+ok
+ok
+===DONE===
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)
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)
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)
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)
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)
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)
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)
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)
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";
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
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";
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
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";
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
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)
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)