From a3c28edfbb7ba240705a38c3d7568fbcb0cd5fab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 May 2021 10:34:49 +0200 Subject: [PATCH] Fix regenerate wrapper when rebuilding cache --- htdocs/core/lib/website2.lib.php | 4 ++-- htdocs/website/class/website.class.php | 15 +++++++++++---- htdocs/website/index.php | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 8824d9cc06d..721b908b9d1 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -283,11 +283,11 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, /** - * Save content of the index.php and/or wrapper.php page + * Save content of the index.php and/or the wrapper.php page * * @param string $pathofwebsite Path of website root * @param string $fileindex Full path of file index.php - * @param string $filetpl File tpl the index.php page redirect to + * @param string $filetpl File tpl the index.php page redirect to (used only if $fileindex is provided) * @param string $filewrapper Full path of file wrapper.php * @return boolean True if OK */ diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index ef50a1701d7..7e70bfddc6d 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -636,7 +636,7 @@ class Website extends CommonObject } /** - * Load an object from its id and create a new one in database. + * Load a website its id and create a new one in database. * This copy website directories, regenerate all the pages + alias pages and recreate the medias link. * * @param User $user User making the clone @@ -777,8 +777,8 @@ class Website extends CommonObject $filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php'; $filewrapper = $pathofwebsitenew.'/wrapper.php'; - // Generate the index.php page to be the home page - //------------------------------------------------- + // Re-generates the index.php page to be the home page, and re-generates the wrapper.php + //-------------------------------------------------------------------------------------- $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper); } } @@ -1278,7 +1278,7 @@ class Website extends CommonObject } /** - * Rebuild all files of a containers of a website. TODO Add other files too. + * Rebuild all files of a containers of a website. Rebuild also the wrapper.php file. TODO Add other files too. * Note: Files are already regenerated during importWebSite so this function is useless when importing a website. * * @return int <0 if KO, >=0 if OK @@ -1347,6 +1347,13 @@ class Website extends CommonObject $i++; } + if (!$error) { + // Save wrapper.php + $pathofwebsite = $conf->website->dir_output.'/'.$object->ref; + $filewrapper = $pathofwebsite.'/wrapper.php'; + dolSaveIndexPage($pathofwebsite, '', '', $filewrapper); + } + if ($error) { return -1; } else { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 69ff8127e6c..ef5660ce8fa 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1083,7 +1083,7 @@ if ($action == 'addcontainer' && $usercanedit) { } else { $filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php'; - // Generate the index.php page (to be the home page) and wrapper.php file + // Generate the index.php page (to be the home page) and the wrapper.php file $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper); if ($result <= 0) { @@ -1315,7 +1315,7 @@ if (!GETPOSTISSET('pageid')) { } } -// Update css Update site properties +// Update css site properties. Re-generates also the wrapper. if ($action == 'updatecss' && $usercanedit) { // If we tried to reload another site/page, we stay on editcss mode. if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) {