commit version 22.12.12447

This commit is contained in:
2023-01-01 22:36:12 -05:00
parent af1b03d79f
commit b948283a96
744 changed files with 620715 additions and 27381 deletions

View File

@ -19,6 +19,7 @@
if (PHP_VERSION_ID < 50600) {
// Disable phpFastCache for PHP less than 5.6, since it unsupported
$config['cache']['enable'] = FALSE;
$config['cache']['enable_cli'] = FALSE;
}
/**
@ -445,22 +446,12 @@ function get_cache_stats() {
define('OBS_CACHE_DEBUG', isset($_SERVER['PATH_INFO']) && str_contains($_SERVER['PATH_INFO'], 'cache_info'));
// Do not load phpFastCache classes if caching mechanism not enabled or not supported
if (!$config['cache']['enable']) {
if (OBS_CACHE_DEBUG || (defined('OBS_DEBUG') && OBS_DEBUG)) {
if (PHP_VERSION_ID < 50600) {
print_error('<span class="text-danger">CACHE DISABLED.</span> You use too old php version, see <a href="' . OBSERVIUM_DOCS_URL . '/software_requirements/">minimum software requirements</a>.');
} else {
print_error('<span class="text-danger">CACHE DISABLED.</span> Disabled in config.');
}
}
return;
}
if (is_cli()) {
if (!$config['cache']['enable_cli'] || OBS_PROCESS_NAME === 'config_to_json') {
if (!$config['cache']['enable_cli'] ||
!in_array(OBS_PROCESS_NAME, [ 'poller', 'discovery', 'syslog' ], TRUE)) {
// FIXME. Do not enable caching in cli when process run as root?
if (OBS_CACHE_DEBUG || (defined('OBS_DEBUG') && OBS_DEBUG)) {
print_cli('%RCACHE DISABLED.%n Disabled in config.');
print_cli('%RCACHE DISABLED.%n Disabled in config or not allowed for '.OBS_PROCESS_NAME.' process.');
}
return;
}
@ -468,6 +459,18 @@ if (is_cli()) {
// Syslog have different dir permissions
$cache_key = OBS_PROCESS_NAME === 'syslog' ? 'syslog' : 'cli';
} else {
// Do not load phpFastCache classes if caching mechanism not enabled or not supported
if (!$config['cache']['enable']) {
if (OBS_CACHE_DEBUG || (defined('OBS_DEBUG') && OBS_DEBUG)) {
if (PHP_VERSION_ID < 50600) {
print_error('<span class="text-danger">CACHE DISABLED.</span> You use too old php version, see <a href="' . OBSERVIUM_DOCS_URL . '/software_requirements/">minimum software requirements</a>.');
} else {
print_error('<span class="text-danger">CACHE DISABLED.</span> Disabled in config.');
}
}
return;
}
$cache_key = 'wui'; // do not use $_SERVER['hostname'] as key
}
@ -586,10 +589,14 @@ switch($cache_driver) {
$GLOBALS[OBS_CACHE_LINK] = CacheManager::getInstance($cache_driver);
} catch (Exception $e) {
print_debug('Cache driver '.ucfirst($cache_driver).' not functional. Caching disabled!');
print_debug_vars($cache_config);
//logfile('debug.log', 'Cache driver '.ucfirst($cache_driver).' not functional. Caching disabled in '.OBS_PROCESS_NAME);
//CacheManager::setDefaultConfig(new \Phpfastcache\Drivers\Devfalse\Config());
//$GLOBALS[OBS_CACHE_LINK] = CacheManager::getInstance('Devfalse'); // disable caching
CacheManager::setDefaultConfig(new \Phpfastcache\Drivers\Devnull\Config());
if (PHP_VERSION_ID >= 70300) {
// Derp compatibility with old
CacheManager::setDefaultConfig(new \Phpfastcache\Drivers\Devnull\Config());
}
$GLOBALS[OBS_CACHE_LINK] = CacheManager::getInstance('Devnull'); // disable caching
}
break;