diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5ce798c0867..8ebdcdd9def 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7977,7 +7977,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 cdd87ed90ac..3a7f94f4f84 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 0eddbc87b18..2ed4b9a75a3 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 @@ -572,7 +572,7 @@ class WebsitePage extends CommonObject if (!$error) { $result = $this->deleteCommon($user, $trigger); - if ($result > 0) + if ($result <= 0) { $error++; } @@ -593,10 +593,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 f23cc45ebf6..048d7f89104 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -86,7 +86,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