Skip to content

[PHP] Fix MEMFS symlink crash during PHP runtime rotation#3500

Merged
mho22 merged 2 commits intotrunkfrom
copy-memfs-symlinks-on-runtime-rotation
Apr 21, 2026
Merged

[PHP] Fix MEMFS symlink crash during PHP runtime rotation#3500
mho22 merged 2 commits intotrunkfrom
copy-memfs-symlinks-on-runtime-rotation

Conversation

@mho22
Copy link
Copy Markdown
Collaborator

@mho22 mho22 commented Apr 16, 2026

Motivation for the change, related issues

copyMEMFSNodes crashes when it encounters a symlink to a directory during PHP runtime rotation. This happens because lookupPath defaults to { follow: true }, which resolves the symlink and treats it as a regular directory, leading to incorrect copying and crashes.

Implementation details

In copyMEMFSNodes, use lookupPath with { follow: false } to detect symlinks before following them. When a symlink is found, recreate it via symlink() instead of attempting to copy the target's contents.

Testing Instructions (or ideally a Blueprint)

CI

@mho22 mho22 marked this pull request as ready for review April 16, 2026 12:39
@mho22 mho22 requested review from a team, JanJakes and Copilot April 16, 2026 12:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a crash during PHP runtime rotation when copying MEMFS nodes that include directory symlinks, by preserving symlinks instead of incorrectly treating them as real directories.

Changes:

  • Update MEMFS copy logic to detect symlinks via lookupPath(..., { follow: false }) and recreate them with symlink().
  • Add a regression test ensuring MEMFS symlinks and subsequent entries survive runtime rotation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/php-wasm/universal/src/lib/php.ts Prevents symlink-to-directory from being followed during MEMFS copy; recreates symlink in target FS.
packages/php-wasm/node/src/test/rotate-php-runtime.spec.ts Adds a test covering symlink preservation across runtime recreation/rotation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/php-wasm/universal/src/lib/php.ts
Comment thread packages/php-wasm/node/src/test/rotate-php-runtime.spec.ts
Copy link
Copy Markdown
Member

@JanJakes JanJakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch!

@mho22 mho22 merged commit 22ca478 into trunk Apr 21, 2026
47 checks passed
@mho22 mho22 deleted the copy-memfs-symlinks-on-runtime-rotation branch April 21, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants