fix : saveSiteSettings et saveSmtpSettings retournent bool, erreur affichée

file_put_contents() échouait silencieusement (permissions), provoquant
un saved=1 trompeur. Les deux fonctions retournent maintenant bool ;
les callers redirigent vers ?error=write et le template affiche un
message d'erreur explicite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 00:02:54 +02:00
parent d6b75d44e3
commit 9091a00a32
4 changed files with 17 additions and 12 deletions
+5 -4
View File
@@ -2293,6 +2293,7 @@ switch ($action) {
$tab = $_GET['tab'] ?? (isAdmin() ? 'dashboard' : 'articles');
$adminData = [];
$siteSettingsSaved = isset($_GET['saved']);
$siteSettingsError = ($_GET['error'] ?? '') === 'write';
if ($tab === 'dashboard') {
if (!isAdmin()) {
@@ -2549,7 +2550,7 @@ switch ($action) {
}
require_once BASE_PATH . '/src/SmtpSettings.php';
saveSmtpSettings([
$ok = saveSmtpSettings([
'host' => $_POST['smtp_host'] ?? '',
'port' => $_POST['smtp_port'] ?? '',
'secure' => $_POST['smtp_secure'] ?? '',
@@ -2558,7 +2559,7 @@ switch ($action) {
'from' => $_POST['smtp_from'] ?? '',
'from_name' => $_POST['smtp_from_name'] ?? '',
]);
header('Location: /admin/smtp?saved=1');
header('Location: /admin/smtp?' . ($ok ? 'saved=1' : 'error=write'));
exit;
case 'admin_smtp_test':
@@ -2774,7 +2775,7 @@ switch ($action) {
http_response_code(403);
exit;
}
saveSiteSettings([
$ok = saveSiteSettings([
'site_title' => $_POST['site_title'] ?? '',
'site_claim' => $_POST['site_claim'] ?? '',
'site_lang' => $_POST['site_lang'] ?? '',
@@ -2782,7 +2783,7 @@ switch ($action) {
'site_license_label' => $_POST['site_license_label'] ?? '',
'site_license_url' => $_POST['site_license_url'] ?? '',
]);
header('Location: /admin/site?saved=1');
header('Location: /admin/site?' . ($ok ? 'saved=1' : 'error=write'));
exit;
case 'admin_create_role':