From 747c49862c0ea0795a240edaed579aee71ba7f45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Sep 2015 19:15:45 +0200 Subject: [PATCH] Try to solve a flush pb --- htdocs/admin/security.php | 6 +++++- htdocs/core/lib/security2.lib.php | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 0eeef2cbe15..84c5ecb92e4 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -126,7 +126,9 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(1); if ($result > 0) { - // database value not required + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); exit; @@ -141,6 +143,8 @@ else if ($action == 'disable_encryptdbpassconf') $result = encodedecode_dbpassconf(0); if ($result > 0) { + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); header("Location: security.php"); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 3297047bef5..0d94357a201 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -416,7 +416,10 @@ function encodedecode_dbpassconf($level=0) if ($fp = @fopen($file,'w')) { fputs($fp, $config); + fflush($fp); fclose($fp); + clearstatcache(); + // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch //@chmod($file, octdec('0600'));