修复系统设置中存在特殊字符导致异常的问题

This commit is contained in:
Chenx221 2024-05-25 01:14:29 +08:00
parent e9f09faad1
commit 610609cd93
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

View File

@ -175,8 +175,13 @@ class SiteConfig extends Model
$data = array_map(function ($key, $value) { $data = array_map(function ($key, $value) {
return "$key=$value"; return "$key=$value";
}, array_keys($env), $env); }, array_keys($env), $env);
return !(file_put_contents(Yii::getAlias('@app/.env'), implode("\n", $data)) == false); file_put_contents(Yii::getAlias('@app/.env.pending'), implode("\n", $data));
} catch (Exception) { parse_ini_file(Yii::getAlias('@app/.env.pending'));
$result= file_put_contents(Yii::getAlias('@app/.env.pending'), implode("\n", $data)) == false;
unlink(Yii::getAlias('@app/.env.pending'));
return !($result);
} catch (Exception $e) {
unlink(Yii::getAlias('@app/.env.pending'));
return false; return false;
} }
} }