aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe/src/config.rs14
-rw-r--r--crates/shirabe/tests/downloader/file_downloader_test.rs1
2 files changed, 5 insertions, 10 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)
diff --git a/crates/shirabe/tests/downloader/file_downloader_test.rs b/crates/shirabe/tests/downloader/file_downloader_test.rs
index 451b792e..623ac34c 100644
--- a/crates/shirabe/tests/downloader/file_downloader_test.rs
+++ b/crates/shirabe/tests/downloader/file_downloader_test.rs
@@ -196,7 +196,6 @@ fn test_download_with_custom_cache_key() {
#[test]
#[serial]
-#[ignore = "PHP Config::get('cache-files-ttl') casts the string via (int) (Config.php:396-398), turning '99999999' into 99999999, but shirabe's PhpMixed::as_int returns None for String so Config::get yields 0 and the assertion fails. Faithful port stays failing until the src is fixed."]
fn test_cache_garbage_collection_is_called() {
let expected_ttl: i64 = 99999999;