Validate queue driver configuration before saving

This commit is contained in:
Kijin Sung 2024-10-12 01:35:13 +09:00
parent 0ee9747a22
commit 36af489b15
7 changed files with 80 additions and 6 deletions

View file

@ -68,7 +68,7 @@ class Queue extends Base
}
// Validate required and optional driver settings.
$driver_config = array();
$driver_config = [];
foreach ($drivers[$driver]['required'] as $conf_name)
{
$conf_value = trim($vars->{'queue_' . $driver . '_' . $conf_name} ?? '');
@ -105,6 +105,18 @@ class Queue extends Base
throw new Exception('msg_queue_invalid_key');
}
// Validate actual operation of the driver.
$driver_class = '\\Rhymix\\Framework\\Drivers\\Queue\\' . $driver;
if (!class_exists($driver_class) || !$driver_class::isSupported())
{
throw new Exception('msg_queue_driver_not_found');
}
if (!$driver_class::validateConfig($driver_config))
{
throw new Exception('msg_queue_driver_not_usable');
}
// Save system config.
Config::set("queue.enabled", $enabled);
Config::set("queue.driver", $driver);