From 0823b3ed1552b4b48b7faa1e95302a083963f0d0 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 11 Feb 2026 21:40:48 +0530 Subject: [PATCH 1/4] ext/standard Deprecate passing empty string to realpath() --- ext/standard/file.c | 4 ++++ ext/standard/tests/file/realpath_empty_string.phpt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 ext/standard/tests/file/realpath_empty_string.phpt diff --git a/ext/standard/file.c b/ext/standard/file.c index a7b73f1fe56eb..f019e1f94ed63 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -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; diff --git a/ext/standard/tests/file/realpath_empty_string.phpt b/ext/standard/tests/file/realpath_empty_string.phpt new file mode 100644 index 0000000000000..4e8b3d7fd6f7c --- /dev/null +++ b/ext/standard/tests/file/realpath_empty_string.phpt @@ -0,0 +1,11 @@ +--TEST-- +realpath() emits deprecation warning when passing empty string +--FILE-- + +--EXPECTF-- +Deprecated: realpath(): Passing empty string to realpath() is deprecated, use getcwd() instead in %s on line %d +string(%d) "%s" From 25ac1a705f325bb9e64693816115d271e8c5fd69 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 11 Feb 2026 22:04:33 +0530 Subject: [PATCH 2/4] ext/standard Deprecate passing empty string to realpath() --- ext/standard/tests/file/readlink_realpath_variation3.phpt | 4 ++++ ext/standard/tests/file/realpath_bug77484.phpt | 1 + 2 files changed, 5 insertions(+) diff --git a/ext/standard/tests/file/readlink_realpath_variation3.phpt b/ext/standard/tests/file/readlink_realpath_variation3.phpt index 44a53f0dfb353..1644f005073fa 100644 --- a/ext/standard/tests/file/readlink_realpath_variation3.phpt +++ b/ext/standard/tests/file/readlink_realpath_variation3.phpt @@ -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 diff --git a/ext/standard/tests/file/realpath_bug77484.phpt b/ext/standard/tests/file/realpath_bug77484.phpt index 9aa3a335c2a96..39a3ae44f0356 100644 --- a/ext/standard/tests/file/realpath_bug77484.phpt +++ b/ext/standard/tests/file/realpath_bug77484.phpt @@ -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) From dad4fc7704b41dab231b5434491c163213fb9d2b Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 11 Feb 2026 23:01:27 +0530 Subject: [PATCH 3/4] @arshidkv12 ext/standard Deprecate passing empty string to realpath() --- ext/standard/tests/file/realpath_variation-win32.phpt | 4 ++++ ext/standard/tests/file/tempnam_variation3-win32.phpt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ext/standard/tests/file/realpath_variation-win32.phpt b/ext/standard/tests/file/realpath_variation-win32.phpt index 1ea8ced7d0eaa..b423c4e81a044 100644 --- a/ext/standard/tests/file/realpath_variation-win32.phpt +++ b/ext/standard/tests/file/realpath_variation-win32.phpt @@ -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 diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt index 5bc4f5ec884d1..c57c12d9aa7ea 100644 --- a/ext/standard/tests/file/tempnam_variation3-win32.phpt +++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt @@ -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 -- From ccdd0384f3f4652fd8b282b49c5e89c1bb4204f9 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 11 Feb 2026 23:43:24 +0530 Subject: [PATCH 4/4] ext/standard Deprecate passing empty string to realpath() --- ext/standard/tests/file/realpath_variation-win32-mb.phpt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/standard/tests/file/realpath_variation-win32-mb.phpt b/ext/standard/tests/file/realpath_variation-win32-mb.phpt index ea2f1c6feca15..35a740ee5a4d3 100644 --- a/ext/standard/tests/file/realpath_variation-win32-mb.phpt +++ b/ext/standard/tests/file/realpath_variation-win32-mb.phpt @@ -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