Skip to content
Open
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
4 changes: 4 additions & 0 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,10 @@ PHP_FUNCTION(realpath)
Z_PARAM_PATH(filename, filename_len)
ZEND_PARSE_PARAMETERS_END();

if (filename_len == 0) {
php_error_docref(NULL, E_DEPRECATED, "Passing empty string to realpath() is deprecated, use getcwd() instead");
}

if (VCWD_REALPATH(filename, resolved_path_buff)) {
if (php_check_open_basedir(resolved_path_buff)) {
RETURN_FALSE;
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/tests/file/readlink_realpath_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ bool(false)

Warning: readlink(): %s in %s on line %d
bool(false)

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
-- Iteration4 --

Warning: readlink(): %s in %s on line %d
bool(false)

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
Done
1 change: 1 addition & 0 deletions ext/standard/tests/file/realpath_bug77484.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ $rp2 = realpath('./');
var_dump($old_cwd, $new_cwd, $rp0, $rp1, $rp2);
?>
--EXPECTF--
Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
bool(false)
bool(false)
Expand Down
11 changes: 11 additions & 0 deletions ext/standard/tests/file/realpath_empty_string.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
realpath() emits deprecation warning when passing empty string
--FILE--
<?php

var_dump(realpath(""));

?>
--EXPECTF--
Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
4 changes: 4 additions & 0 deletions ext/standard/tests/file/realpath_variation-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ bool(false)
-- Iteration2 --
bool(false)
-- Iteration3 --

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
-- Iteration4 --

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
Done
4 changes: 4 additions & 0 deletions ext/standard/tests/file/realpath_variation-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ bool(false)
-- Iteration2 --
bool(false)
-- Iteration3 --

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
-- Iteration4 --

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
string(%d) "%s"
Done
4 changes: 4 additions & 0 deletions ext/standard/tests/file/tempnam_variation3-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ OK
-- Iteration 4 --

Notice: tempnam(): file created in the system's temporary directory in %stempnam_variation3-win32.php on line %d

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d

Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
Failed, not created in the correct directory %s vs %s
0
-- Iteration 5 --
Expand Down
Loading