From 8b9368a3d2c8cb5b73edc794b77ebd2460d24b06 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 20 Jul 2026 06:28:13 +0900 Subject: fix(config): restore PHP (int) cast for ttl and timeout values PHP's Config::get() applies an (int) cast to cache-files-ttl, cache-ttl, and the process-timeout env override (Config.php:326,367,398), so string values like '99999999' become integers. The strict PhpMixed::as_int returned None for strings, collapsing them to 0. Use the intval shim, which implements the PHP cast, and un-ignore test_cache_garbage_collection_is_called which this had blocked. Co-Authored-By: Claude Fable 5 --- crates/shirabe/src/config.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src') diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs index bc172bd2..966d6bac 100644 --- a/crates/shirabe/src/config.rs +++ b/crates/shirabe/src/config.rs @@ -12,8 +12,8 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ E_USER_DEPRECATED, PHP_URL_HOST, PHP_URL_SCHEME, PhpMixed, RuntimeException, array_key_exists, array_merge, array_search_mixed, array_unique, empty, filter_var_url, implode, in_array, - is_array, is_string, parse_url, php_regex, php_to_string, rtrim, strtolower, strtoupper, strtr, - substr, trigger_error, + intval, is_array, is_string, parse_url, php_regex, php_to_string, rtrim, strtolower, + strtoupper, strtr, substr, trigger_error, }; use crate::advisory::Auditor; @@ -598,7 +598,7 @@ impl Config { } else { val.clone() }; - return Ok(PhpMixed::Int(raw.as_int().unwrap_or(0).max(0))); + return Ok(PhpMixed::Int(intval(&raw).max(0))); } let raw_val = if matches!(val, PhpMixed::Bool(false)) { @@ -659,11 +659,7 @@ impl Config { // ints without env var support "cache-ttl" => Ok(PhpMixed::Int( - self.config - .get(key) - .and_then(|v| v.as_int()) - .unwrap_or(0) - .max(0), + self.config.get(key).map(intval).unwrap_or(0).max(0), )), // numbers with kb/mb/gb support, without env var support @@ -720,7 +716,7 @@ impl Config { if let Some(v) = v && !v.is_null() { - return Ok(PhpMixed::Int(v.as_int().unwrap_or(0).max(0))); + return Ok(PhpMixed::Int(intval(&v).max(0))); } self.get_with_flags("cache-ttl", 0) -- cgit v1.3.1