Fix: task #11248 : there is no DB transaction on products->delete

Qual: Mutualize code to see of an object as child
This commit is contained in:
Laurent Destailleur 2011-08-28 12:57:23 +00:00
parent 058636e01b
commit be5333589e
4 changed files with 563 additions and 564 deletions

View File

@ -571,20 +571,6 @@ class Product extends CommonObject
}
}
if (! $error)
{
$sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product";
$sqlz.= " WHERE rowid = ".$id;
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
$resultz = $this->db->query($sqlz);
if ( ! $resultz )
{
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
}
}
if (! $error)
{
// Actions on extra fields (by external module or standard code)
@ -606,6 +592,21 @@ class Product extends CommonObject
}
}
// Delete product
if (! $error)
{
$sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product";
$sqlz.= " WHERE rowid = ".$id;
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
$resultz = $this->db->query($sqlz);
if ( ! $resultz )
{
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
}
}
if (! $error)
{
// Appel des triggers

File diff suppressed because it is too large Load Diff

View File

@ -938,20 +938,6 @@ class Societe extends CommonObject
}
}
// Remove third party
if (! $error)
{
$sql = "DELETE from ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::delete erreur -3 ".$this->error, LOG_ERR);
}
}
if (! $error)
{
// Actions on extra fields (by external module or standard code)
@ -973,6 +959,20 @@ class Societe extends CommonObject
}
}
// Remove third party
if (! $error)
{
$sql = "DELETE from ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::delete erreur -3 ".$this->error, LOG_ERR);
}
}
if (! $error)
{
// Appel des triggers

View File

@ -424,9 +424,9 @@ if (empty($reshook))
$object->fetch($socid);
$result = $object->delete($socid);
if ($result >= 0)
if ($result > 0)
{
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$object->nom."");
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".urlencode($object->name));
exit;
}
else
@ -498,6 +498,7 @@ $formcompany = new FormCompany($db);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
// TODO Mutualize this part of code (same than product/fiche.php and contact/fiche.php)
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{
@ -538,6 +539,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
}
else
{
// -----------------------------------------
// When used in standard mode
// -----------------------------------------