Skip to content

Commit 0823b3e

Browse files
committed
ext/standard Deprecate passing empty string to realpath()
1 parent defc0be commit 0823b3e

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

ext/standard/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,10 @@ PHP_FUNCTION(realpath)
21062106
Z_PARAM_PATH(filename, filename_len)
21072107
ZEND_PARSE_PARAMETERS_END();
21082108

2109+
if (filename_len == 0) {
2110+
php_error_docref(NULL, E_DEPRECATED, "Passing empty string to realpath() is deprecated, use getcwd() instead");
2111+
}
2112+
21092113
if (VCWD_REALPATH(filename, resolved_path_buff)) {
21102114
if (php_check_open_basedir(resolved_path_buff)) {
21112115
RETURN_FALSE;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
realpath() emits deprecation warning when passing empty string
3+
--FILE--
4+
<?php
5+
6+
var_dump(realpath(""));
7+
8+
?>
9+
--EXPECTF--
10+
Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d
11+
string(%d) "%s"

0 commit comments

Comments
 (0)