Fix bad definition of field for parent

This commit is contained in:
Laurent Destailleur 2020-06-11 18:31:26 +02:00
parent c70cd01971
commit ee611fa7a0
4 changed files with 15 additions and 7 deletions

View File

@ -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++;

View File

@ -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';

View File

@ -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;
}
}
/**

View File

@ -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