Merge pull request #11896 from tuxgasy/10.0_childtablesoncascade_isempty

Check if childtablesoncascade is not empty
This commit is contained in:
Laurent Destailleur 2019-09-15 10:16:07 +02:00 committed by GitHub
commit f946ec0563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7536,18 +7536,20 @@ abstract class CommonObject
} }
// Delete cascade first // Delete cascade first
foreach($this->childtablesoncascade as $table) if (! empty($this->childtablesoncascade)) {
{ foreach($this->childtablesoncascade as $table)
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; {
$resql = $this->db->query($sql); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id;
if (! $resql) $resql = $this->db->query($sql);
{ if (! $resql)
$this->error=$this->db->lasterror(); {
$this->errors[]=$this->error; $this->error=$this->db->lasterror();
$this->db->rollback(); $this->errors[]=$this->error;
return -1; $this->db->rollback();
} return -1;
} }
}
}
if (! $error) { if (! $error) {
if (! $notrigger) { if (! $notrigger) {