Skip to content

Commit

Permalink
fix website purge function
Browse files Browse the repository at this point in the history
  • Loading branch information
Daoud-mohamed committed Jan 7, 2025
1 parent bd8a839 commit 75f23fc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions htdocs/website/class/website.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ public function delete(User $user, $notrigger = 0)
*/
public function purge(User $user)
{
global $conf;
global $conf, $langs;

dol_syslog(__METHOD__, LOG_DEBUG);

Expand All @@ -684,8 +684,22 @@ public function purge(User $user)

if (!$error && !empty($this->ref)) {
$pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref;
// Delete content of website directory without deleting the website directory
dol_delete_dir_recursive($pathofwebsite, 0, 0, 1);

dol_delete_dir_recursive($pathofwebsite);
// Check symlink documents/website/mywebsite/medias to point to documents/medias and restore it if ko.
// Recreate also dir of website if not found.
$pathtomedias = DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite = $pathofwebsite.'/medias';
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists
$result = symlink($pathtomedias, $pathtomediasinwebsite);
if (!$result) {
$this->errors[] = $langs->trans("ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias);
$error++;
}
}
}

// Commit or rollback
Expand Down

0 comments on commit 75f23fc

Please sign in to comment.