mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-30 05:11:27 +01:00
FIX: Better error management in loading a website template
This commit is contained in:
@@ -857,14 +857,14 @@ function dol_copy($srcfile, $destfile, $newmask = '0', $overwriteifexists = 1, $
|
||||
/**
|
||||
* Copy a dir to another dir. This include recursive subdirectories.
|
||||
*
|
||||
* @param string $srcfile Source file (a directory)
|
||||
* @param string $destfile Destination file (a directory)
|
||||
* @param string $newmask Mask for new file ('0' by default means getDolGlobalString('MAIN_UMASK')). Example: '0666'
|
||||
* @param int $overwriteifexists Overwrite file if exists (1 by default)
|
||||
* @param string $srcfile Source file (a directory)
|
||||
* @param string $destfile Destination file (a directory)
|
||||
* @param string $newmask Mask for new file ('0' by default means getDolGlobalString('MAIN_UMASK')). Example: '0666'
|
||||
* @param int $overwriteifexists Overwrite file if exists (1 by default)
|
||||
* @param array<string,string> $arrayreplacement Array to use to replace filenames with another one during the copy (works only on file names, not on directory names).
|
||||
* @param int $excludesubdir 0=Do not exclude subdirectories, 1=Exclude subdirectories, 2=Exclude subdirectories if name is not a 2 chars (used for country codes subdirectories).
|
||||
* @param string[] $excludefileext Exclude some file extensions
|
||||
* @return int Return integer <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK
|
||||
* @param int $excludesubdir 0=Do not exclude subdirectories, 1=Exclude subdirectories, 2=Exclude subdirectories if name is not a 2 chars (used for country codes subdirectories).
|
||||
* @param string[] $excludefileext Exclude some file extensions
|
||||
* @return int Return integer <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK
|
||||
* @see dol_copy()
|
||||
*/
|
||||
function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement = null, $excludesubdir = 0, $excludefileext = null)
|
||||
@@ -878,6 +878,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
|
||||
}
|
||||
|
||||
$destexists = dol_is_dir($destfile);
|
||||
|
||||
//if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only.
|
||||
|
||||
if (!$destexists) {
|
||||
@@ -888,7 +889,13 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
|
||||
$dirmaskdec = octdec(getDolGlobalString('MAIN_UMASK'));
|
||||
}
|
||||
$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
|
||||
dol_mkdir($destfile, '', decoct($dirmaskdec));
|
||||
|
||||
$result = dol_mkdir($destfile, '', decoct($dirmaskdec));
|
||||
|
||||
if (!dol_is_dir($destfile)) {
|
||||
// The output directory does not exists and we failed to create it. So we stop here.
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$ossrcfile = dol_osencode($srcfile);
|
||||
|
||||
@@ -7424,7 +7424,7 @@ function dol_mkdir($dir, $dataroot = '', $newmask = '')
|
||||
}
|
||||
$dirmaskdec |= octdec('0111'); // Set x bit required for directories
|
||||
if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
|
||||
// Si le is_dir a renvoye une fausse info, alors on passe ici.
|
||||
// If the is_dir has returned a false information, we arrive here
|
||||
dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.", LOG_WARNING);
|
||||
$nberr++;
|
||||
} else {
|
||||
|
||||
@@ -1262,8 +1262,17 @@ class Website extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
|
||||
dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists
|
||||
dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists
|
||||
$result = dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1);
|
||||
if ($result < 0) {
|
||||
$this->errors[] = 'Failed to copy files into '.$conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref.'.';
|
||||
return -5;
|
||||
}
|
||||
|
||||
$result = dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1);
|
||||
if ($result < 0) {
|
||||
$this->errors[] = 'Failed to copy files into '.$conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref.'.';
|
||||
return -5;
|
||||
}
|
||||
|
||||
$sqlfile = $conf->website->dir_temp."/".$object->ref.'/website_pages.sql';
|
||||
|
||||
@@ -1301,13 +1310,13 @@ class Website extends CommonObject
|
||||
$newid = ($reg[2] + $maxrowid);
|
||||
$aliasesarray = explode(',', $reg[3]);
|
||||
|
||||
dol_syslog("Found ID ".$oldid." to replace with ID ".$newid." and shortcut aliases to create: ".$reg[3]);
|
||||
dol_syslog("In sql source file, we have the page ID ".$oldid." to replace with the new ID ".$newid.", and we must create the shortcut aliases: ".$reg[3]);
|
||||
|
||||
dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0);
|
||||
//dol_move($conf->website->dir_output.'/'.$object->ref.'/page'.$oldid.'.tpl.php', $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php', 0, 1, 0, 0);
|
||||
|
||||
$objectpagestatic->fetch($newid);
|
||||
|
||||
// The move is not enough, so we regenerate pageX.tpl.php
|
||||
// We regenerate the pageX.tpl.php
|
||||
$filetpl = $conf->website->dir_output.'/'.$object->ref.'/page'.$newid.'.tpl.php';
|
||||
$result = dolSavePageContent($filetpl, $object, $objectpagestatic);
|
||||
if (!$result) {
|
||||
|
||||
Reference in New Issue
Block a user