Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Website Purge Function #32554

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading