From 96b010a735f191c6e430de9c16e47e49f3f653cd Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Wed, 16 Aug 2017 19:58:10 +0100 Subject: [PATCH] feature: Forced OS Cache rebuild for unit tests (#7163) --- includes/common.php | 7 ++++--- tests/bootstrap.php | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/common.php b/includes/common.php index 59de1fec2a..7f93b032cd 100644 --- a/includes/common.php +++ b/includes/common.php @@ -1646,15 +1646,16 @@ function load_all_os($existing = false, $cached = true) } /** - * Update the OS cache file cache/os_defs.cache + * * Update the OS cache file cache/os_defs.cache + * @param bool $force */ -function update_os_cache() +function update_os_cache($force = false) { global $config; $cache_file = $config['install_dir'] . '/cache/os_defs.cache'; $cache_keep_time = $config['os_def_cache_time'] - 7200; // 2hr buffer - if (!is_file($cache_file) || time() - filemtime($cache_file) > $cache_keep_time) { + if ($force === true || !is_file($cache_file) || time() - filemtime($cache_file) > $cache_keep_time) { d_echo('Updating os_def.cache... '); load_all_os(false, false); file_put_contents($cache_file, serialize($config['os'])); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 90a977674b..b44206ac68 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -47,6 +47,7 @@ chdir($install_dir); ini_set('display_errors', 1); error_reporting(E_ALL & ~E_WARNING); +update_os_cache(true); // Force update of OS Cache load_all_os(); // pre-load OS so we don't keep loading them if (getenv('DBTEST')) {