From ced1f9aa91ee36857fec9664c9ccd86ba2310821 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 04:47:02 +0900 Subject: refactor(function-exists): drop checks for always-present capabilities function_exists() returns false in PHP when a function is blocked by disable_functions, when its extension is not compiled in, or when the PHP version predates it. None of those apply to a native binary. --- crates/shirabe/src/cache.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/cache.rs') diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs index edfe584c..a8e4fb26 100644 --- a/crates/shirabe/src/cache.rs +++ b/crates/shirabe/src/cache.rs @@ -8,9 +8,9 @@ use crate::util::Silencer; use chrono::Utc; use shirabe_php_shim::{ ErrorException, bin2hex, clearstatcache, date_format_to_strftime, dirname, disk_free_space, - file_exists, file_get_contents, file_put_contents, filemtime, function_exists, hash_file, - is_dir, is_writable, mkdir, php_regex, preg_is_match, preg_match, preg_replace, random_bytes, - random_int, rename, time, unlink, + file_exists, file_get_contents, file_put_contents, filemtime, hash_file, is_dir, is_writable, + mkdir, php_regex, preg_is_match, preg_match, preg_replace, random_bytes, random_int, rename, + time, unlink, }; use shirabe_symfony_finder::Finder; use std::sync::Mutex; @@ -195,13 +195,9 @@ impl Cache { // Remove partial file. unlink(&temp_file_name); - let free_space = if function_exists("disk_free_space") { - disk_free_space(dirname(&temp_file_name)) - .map(|space| space.to_string()) - .unwrap_or_default() - } else { - "unknown".to_string() - }; + let free_space = disk_free_space(dirname(&temp_file_name)) + .map(|space| space.to_string()) + .unwrap_or_default(); let message = format!( "Writing {} into cache failed after {} of {} bytes written, only {} bytes of free space available", temp_file_name, -- cgit v1.3.1-4-g156e