Fix regenerate wrapper when rebuilding cache

This commit is contained in:
Laurent Destailleur 2021-05-20 10:34:49 +02:00
parent 1a8b10328f
commit a3c28edfbb
3 changed files with 15 additions and 8 deletions

View File

@ -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 $pathofwebsite Path of website root
* @param string $fileindex Full path of file index.php * @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 * @param string $filewrapper Full path of file wrapper.php
* @return boolean True if OK * @return boolean True if OK
*/ */

View File

@ -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. * This copy website directories, regenerate all the pages + alias pages and recreate the medias link.
* *
* @param User $user User making the clone * @param User $user User making the clone
@ -777,8 +777,8 @@ class Website extends CommonObject
$filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php'; $filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php';
$filewrapper = $pathofwebsitenew.'/wrapper.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); $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. * Note: Files are already regenerated during importWebSite so this function is useless when importing a website.
* *
* @return int <0 if KO, >=0 if OK * @return int <0 if KO, >=0 if OK
@ -1347,6 +1347,13 @@ class Website extends CommonObject
$i++; $i++;
} }
if (!$error) {
// Save wrapper.php
$pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
$filewrapper = $pathofwebsite.'/wrapper.php';
dolSaveIndexPage($pathofwebsite, '', '', $filewrapper);
}
if ($error) { if ($error) {
return -1; return -1;
} else { } else {

View File

@ -1083,7 +1083,7 @@ if ($action == 'addcontainer' && $usercanedit) {
} else { } else {
$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php'; $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); $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper);
if ($result <= 0) { 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 ($action == 'updatecss' && $usercanedit) {
// If we tried to reload another site/page, we stay on editcss mode. // 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')) { if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) {