From c65cab710bb3d79db20862c9361d4dbbac8ac5d7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 25 Jun 2026 03:20:08 +0900 Subject: feat(php-shim): model $_ENV/$_SERVER as OsString snapshots Rework the environment shim around getenv/putenv on the real environment and $_ENV/$_SERVER as startup snapshots, all over OsString. Migrate every caller off the old server()/server_argv() helpers and force the snapshots in main() before any putenv() runs. Document the porting rules in docs/dev/env-vars-porting.md. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/tests/util/ini_helper_test.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/tests/util') diff --git a/crates/shirabe/tests/util/ini_helper_test.rs b/crates/shirabe/tests/util/ini_helper_test.rs index f511d76..d1e2071 100644 --- a/crates/shirabe/tests/util/ini_helper_test.rs +++ b/crates/shirabe/tests/util/ini_helper_test.rs @@ -12,7 +12,8 @@ fn set_up() -> TearDown { // XdebugHandler is a unit struct with no name-registration API, so this // step is a no-op here. // Save current state - let env_original = getenv("COMPOSER_ORIGINAL_INIS"); + let env_original = + getenv("COMPOSER_ORIGINAL_INIS").map(|value| value.to_string_lossy().into_owned()); TearDown { env_original } } @@ -20,7 +21,7 @@ fn set_up() -> TearDown { fn tear_down(env_original: &Option) { // Restore original state if let Some(env_original) = env_original { - putenv(&format!("COMPOSER_ORIGINAL_INIS={env_original}")); + unsafe { putenv("COMPOSER_ORIGINAL_INIS", env_original) }; } else { Platform::clear_env("COMPOSER_ORIGINAL_INIS"); } @@ -38,10 +39,7 @@ impl Drop for TearDown { } fn set_env(paths: &[&str]) { - putenv(&format!( - "COMPOSER_ORIGINAL_INIS={}", - paths.join(PATH_SEPARATOR) - )); + unsafe { putenv("COMPOSER_ORIGINAL_INIS", paths.join(PATH_SEPARATOR)) }; } #[test] -- cgit v1.3.1