From aa2124fe5d0c96078c034a6e4044b7e81acdf692 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 14:18:41 +0900 Subject: feat(php-rpc): replay Rust-side env writes into the PHP worker The worker is a long-lived child holding the environment it was handed at spawn, so `@putenv`, the bin dir the event dispatcher prepends to PATH, and COMPOSER_DEV_MODE never reached the PHP code running in it. The shim now journals every write to the three storages PHP exposes, and the outermost rpc_call replays the entries the worker has not seen yet through __shirabe_sync_env. Replaying the writes rather than pushing a whole snapshot keeps the worker's own $_SERVER entries intact. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-rpc/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/shirabe-php-rpc/src/lib.rs') diff --git a/crates/shirabe-php-rpc/src/lib.rs b/crates/shirabe-php-rpc/src/lib.rs index d818b364..47304ba8 100644 --- a/crates/shirabe-php-rpc/src/lib.rs +++ b/crates/shirabe-php-rpc/src/lib.rs @@ -1,6 +1,7 @@ //! Rust-to-PHP RPC over a Unix domain socket. See `docs/dev/php-rpc.md`. pub mod composer_runtime; +mod env; pub mod frame; pub mod session; pub mod value; @@ -780,7 +781,10 @@ fn rpc_call( ) -> anyhow::Result> { // Held for the whole logical call session; nested calls from the same thread (issued by a // dispatcher handler) re-enter immediately, other threads are serialized. - let _session = session::SessionGuard::enter(); + let session = session::SessionGuard::enter(); + if session.is_outermost() { + env::flush()?; + } let my_id = NEXT_CORR_ID.fetch_add(2, Ordering::Relaxed); send_frame(&request(my_id))?; loop { -- cgit v1.3.1-4-g156e