aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/config.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-20 06:28:13 +0900
committernsfisis <nsfisis@gmail.com>2026-07-20 06:28:13 +0900
commit8b9368a3d2c8cb5b73edc794b77ebd2460d24b06 (patch)
tree6ec4e7342ece017030da5639064343a1b9677ace /crates/shirabe/src/config.rs
parent8766b9dbc981c827d49658b7bc79d860031c0493 (diff)
downloadphp-shirabe-8b9368a3d2c8cb5b73edc794b77ebd2460d24b06.tar.gz
php-shirabe-8b9368a3d2c8cb5b73edc794b77ebd2460d24b06.tar.zst
php-shirabe-8b9368a3d2c8cb5b73edc794b77ebd2460d24b06.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/config.rs')
-rw-r--r--crates/shirabe/src/config.rs14
1 files changed, 5 insertions, 9 deletions
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)