diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 681e20b18c3..d6fcbd0f7b4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8340,7 +8340,9 @@ abstract class CommonObject break; } } else { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $table . ' WHERE ' . $this->fk_element . ' = ' . $this->id; + // Delete record in child table + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $table . ' WHERE ' . $this->fk_element . ' = ' . $this->id; + $resql = $this->db->query($sql); if (!$resql) { $error++; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fb51c5d152b..2f84ab6c795 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -55,7 +55,7 @@ class Societe extends CommonObject public $table_element = 'societe'; /** - * @var int Field with ID of parent key if this field has a parent + * @var int Field with ID of parent key if this field has a parent or for child tables */ public $fk_element = 'fk_soc'; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 61ec8376414..eb707e3010d 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -173,9 +173,9 @@ class WebsitePage extends CommonObject //public $table_element_line = 'mymodule_myobjectline'; /** - * @var int Field with ID of parent key if this object has a parent + * @var int Field with ID of parent key if this field has a parent or for child tables */ - public $fk_element = 'fk_website'; + public $fk_element = 'fk_website_page'; /** * @var int Name of subtable class that manage subtable lines @@ -573,7 +573,7 @@ class WebsitePage extends CommonObject if (!$error) { $result = $this->deleteCommon($user, $trigger); - if ($result > 0) + if ($result <= 0) { $error++; } @@ -594,10 +594,17 @@ class WebsitePage extends CommonObject dol_delete_file($filealias); dol_delete_file($filetpl); + } else { + $this->error = $websiteobj->error; + $this->errors = $websiteobj->errors; } } - return $result; + if (! $error) { + return 1; + } else { + return -1; + } } /** diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2a3b50df2f6..d539572bc11 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -85,7 +85,6 @@ if (GETPOST('createfromclone', 'alpha')) { $action = 'createfromclone'; } if (GETPOST('createpagefromclone', 'alpha')) { $action = 'createpagefromclone'; } if (empty($action) && $file_manager) $action = 'file_manager'; if (empty($action) && $replacesite) $action = 'replacesite'; - if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) $pageid = 0; // Load variable for pagination