Skip to content

Fix realpath('') empty path — resolve cwd like Zend (#10257) - #10939

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-10257-realpath-empty
Jun 23, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-10257-realpath-empty

Conversation

@PurHur

@PurHur PurHur commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Treat realpath('') as realpath('.') per php-src ext/standard/basic_functions.c php_realpath() empty-path → VCWD_GETCWD behavior
  • Normalize empty path in VmString::realpath(), VmStatNative::realpath(), and JitRealpath LLVM lowering
  • Add compliance guard test/compliance/cases/stdlib/realpath_empty_string.phpt and issue repro script

php-src reference

  • ext/standard/basic_functions.c — php_realpath() empty path uses cwd

PHP implementation

  • ext/standard/VmString.php — VM SSOT
  • ext/standard/VmStatNative.php — libc FFI path
  • ext/standard/JitRealpath.php — JIT empty-string → . select

Closes #10257

Test plan

php bin/vm.php test/repro/maintainer_gap_realpath_empty.php
# '/app/var/workspaces/.../repo'  (cwd string, not false)

php bin/vm.php test/compliance/cases/stdlib/realpath_empty_string.phpt
# ok

Made with Cursor

Empty path strings now normalize to '.' before canonicalization in VM,
JIT, and libc FFI paths so realpath('') matches realpath('.') per
ext/standard/basic_functions.c php_realpath() behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit b843d41 into master Jun 23, 2026
@PurHur
PurHur deleted the agent/issue-10257-realpath-empty branch June 23, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: realpath('') empty path — returns false not cwd (ext/standard/basic_functions.c)

1 participant