Fix: Regression detected by PHPUnit

This commit is contained in:
Laurent Destailleur 2012-12-10 19:06:59 +01:00
parent 88ffda4bfb
commit f4459ee1f1
6 changed files with 45 additions and 38 deletions

View File

@ -715,9 +715,9 @@ class Adherent extends CommonObject
$this->error .= $this->db->lasterror();
$errorflag=-1;
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
// Remove cotisation
if (! $error)
{
@ -732,9 +732,9 @@ class Adherent extends CommonObject
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
// Remove linked user
if (! $error)
if (! $error)
{
$ret=$this->setUserId(0);
if ($ret < 0)
@ -745,21 +745,22 @@ class Adherent extends CommonObject
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
// Removed extrafields
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields($this);
if ($result < 0) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
$errorflag=-4;
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
}
// Remove adherent
if (! $error)
{
@ -774,7 +775,7 @@ class Adherent extends CommonObject
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
if (! $error)
{
// Appel des triggers
@ -784,9 +785,9 @@ class Adherent extends CommonObject
if ($result < 0) {$error++; $this->errors=$interface->errors;}
// Fin appel triggers
}
if (! $error)
{
$this->db->commit();

View File

@ -227,7 +227,7 @@ class ActionComm extends CommonObject
}
}
else if ($reshook < 0) $error++;
if (! $notrigger)
{
// Appel des triggers
@ -367,13 +367,17 @@ class ActionComm extends CommonObject
$this->error=$this->db->lasterror();
$error++;
}
// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields($this);
if ($result < 0) $error++;
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
if (!$error)
{
if (! $notrigger)
@ -468,7 +472,7 @@ class ActionComm extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql);
if ($this->db->query($sql))
{
// Actions on extra fields (by external module or standard code)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
@ -487,7 +491,7 @@ class ActionComm extends CommonObject
}
}
else if ($reshook < 0) $error++;
if (! $notrigger)
{
// Appel des triggers

View File

@ -2069,25 +2069,24 @@ abstract class CommonObject
/**
* Delete all extra fields values for the current object.
*
* @return void
*
* @return int <0 if KO, >0 if OK
*/
function deleteExtraFields()
{
global $langs;
$error=0;
$this->db->begin();
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
dol_syslog(get_class($this)."::insertExtraFields delete sql=".$sql_del);
$this->db->query($sql_del);
dol_syslog(get_class($this)."::deleteExtraFields delete sql=".$sql_del);
$resql=$this->db->query($sql_del);
if (! $resql)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error,LOG_ERR);
dol_syslog(get_class($this)."::deleteExtraFields ".$this->error,LOG_ERR);
$this->db->rollback();
return -1;
}
@ -2256,7 +2255,7 @@ abstract class CommonObject
/**
* Function that returns the total amount of discounts applied.
*
*
* @return false|float False is returned if the discount couldn't be retrieved
*/
function getTotalDiscount()
@ -2264,7 +2263,7 @@ abstract class CommonObject
$sql = 'SELECT (SUM(`subprice`) - SUM(`total_ht`)) as `discount` FROM '.MAIN_DB_PREFIX.$this->table_element.'det WHERE `'.$this->fk_element.'` = '.$this->id;
$query = $this->db->query($sql);
if ($query)
{
$result = $this->db->fetch_object($query);

View File

@ -629,8 +629,9 @@ class Product extends CommonObject
// Removed extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields($this);
if ($result < 0) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
}

View File

@ -1018,7 +1018,7 @@ class Societe extends CommonObject
{
$error++;
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::Delete erreur -2 ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete erreur -2 ".$this->error, LOG_ERR);
}
}
@ -1040,10 +1040,11 @@ class Societe extends CommonObject
// Removed extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields($this);
if ($result < 0) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}

View File

@ -721,8 +721,9 @@ class User extends CommonObject
// Remove extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields($this);
if ($result < 0) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
}