Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,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);
Expand Down
54 changes: 54 additions & 0 deletions ext/standard/tests/file/bug74719.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--TEST--
Bug #74719 Allow NULL as context
--CREDITS--
Alexander Holman <alexander@holman.org.uk>
--FILE--
<?php
/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
* Description: Open a file or a URL and return a file pointer
* Source code: ext/standard/file.c
* Alias to functions:
*/

require_once('fopen_include_path.inc');

$thisTestDir = basename(__FILE__, ".php") . ".dir";
mkdir($thisTestDir);
chdir($thisTestDir);

$newpath = relative_include_path();
set_include_path($newpath);

$tmpfile = basename(__FILE__, ".php") . ".tmp";
$h = fopen($tmpfile, "w", true, NULL);
if ($h === false) {
echo "Unable to open file to write\n";
}
else {
echo "open and write okay\n";
fwrite($h, "This is the test file");
fclose($h);
$h = fopen($tmpfile, "r", false, NULL);
if ($h === false) {
echo "Unable to open file to read file\n";
}
else {
echo "open and read okay\n";
fclose($h);
}
unlink($tmpfile);
}

teardown_relative_path();
restore_include_path();
chdir("..");
rmdir($thisTestDir);

function runtest() {
}
?>
===DONE===
--EXPECT--
open and write okay
open and read okay
===DONE===