fix: 初始化异常

This commit is contained in:
Ying
2022-08-31 08:57:56 +08:00
parent 78aab734e1
commit bc48853cf5
2 changed files with 36 additions and 32 deletions

View File

@@ -582,17 +582,22 @@ if (!function_exists('saenv')) {
{
$redis = 'config_' . $name;
$config = Cache::get($redis);
$configList = Cache::get('config_list') ?? [];
if (empty($config)) {
$config = $group ? Config::all($name, true) : Config::where('name', $name)->value('value');
if (!empty($config)) {
$configList[$name] = $redis;
Cache::set($redis, $config);
Cache::set('config_list', $configList);
}
}
return $config ?: false;
try {
$configList = Cache::get('config_list') ?? [];
if (empty($config)) {
$config = $group ? Config::all($name, true) : Config::where('name', $name)->value('value');
if (!empty($config)) {
$configList[$name] = $redis;
Cache::set($redis, $config);
Cache::set('config_list', $configList);
}
}
} catch (\Exception $e) {}
return $config;
}
}
@@ -661,6 +666,21 @@ if (!function_exists('system_reload')) {
}
}
if (!function_exists('get_routes')) {
/**
* 获取系统配置信息
*/
function get_routes(): array
{
$routeList = [];
$routes = \Webman\Route::getRoutes();
foreach ($routes as $tmp_route) {
$routeList[] = $tmp_route->getPath();
}
return $routeList;
}
}
if (!function_exists('parse_array_ini')) {
/**
* 解析数组到ini文件
@@ -1299,7 +1319,7 @@ if (!function_exists('plugin_refresh_hooks')) {
$parse = explode('/', $route);
$action = end($parse);
array_pop($parse);
$path = implode('/', $parse);
$path = implode('\\', $parse);
$controller = 'app\\index\\controller\\' . $path;
if (class_exists($controller) && method_exists($controller, $action)) {
$controller = preg_replace('#//#', '/', $controller);