From 87e221d6ddfca7864ab414d3e817d318b6a9ac38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 4 Dec 2021 00:24:59 +0100 Subject: [PATCH] Fix create new page --- htdocs/core/lib/website2.lib.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 7b075ad6fb7..fb11846a4fb 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -149,18 +149,20 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, global $conf, $db; // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) - dol_syslog("We regenerate the tpl page filetpl=".$filetpl); + dol_syslog("dolSavePageContent We regenerate the tpl page filetpl=".$filetpl); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($backupold) { - dol_delete_file($filetpl.'.old'); - $result = dol_move($filetpl, $filetpl.'.old', 0, 1, 0, 0); - if (! $result) { - return false; + if (dol_is_file($filetpl)) { + if ($backupold) { + dol_delete_file($filetpl.'.old'); + $result = dol_move($filetpl, $filetpl.'.old', 0, 1, 0, 0); + if (! $result) { + return false; + } + } else { + dol_delete_file($filetpl); } - } else { - dol_delete_file($filetpl); } $shortlangcode = '';