FIX Bad error management into trigger of mailmanspip
This commit is contained in:
parent
a8ba8e612a
commit
f021a8ca31
@ -404,11 +404,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($object->error) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
} else {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -509,7 +509,7 @@ class Adherent extends CommonObject
|
|||||||
if (! $error && $nbrowsaffected) // If something has change in main data
|
if (! $error && $nbrowsaffected) // If something has change in main data
|
||||||
{
|
{
|
||||||
// Update information on linked user if it is an update
|
// Update information on linked user if it is an update
|
||||||
if ($this->user_id > 0 && ! $nosyncuser)
|
if (! $error && $this->user_id > 0 && ! $nosyncuser)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update information on linked thirdparty if it is an update
|
// Update information on linked thirdparty if it is an update
|
||||||
if ($this->fk_soc > 0 && ! $nosyncthirdparty)
|
if (! $error && $this->fk_soc > 0 && ! $nosyncthirdparty)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||||
|
|
||||||
@ -1423,9 +1423,10 @@ class Adherent extends CommonObject
|
|||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
// mailman
|
// mailman
|
||||||
if (! empty($conf->global->ADHERENT_USE_MAILMAN))
|
if (! empty($conf->global->ADHERENT_USE_MAILMAN) && ! empty($conf->mailmanspip->enabled))
|
||||||
{
|
{
|
||||||
$result=$mailmanspip->add_to_mailman($this);
|
$result=$mailmanspip->add_to_mailman($this);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error;
|
if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error;
|
||||||
@ -1444,7 +1445,7 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// spip
|
// spip
|
||||||
if ($conf->global->ADHERENT_USE_SPIP && ! empty($conf->mailmanspip->enabled))
|
if (! empty($conf->global->ADHERENT_USE_SPIP) && ! empty($conf->mailmanspip->enabled))
|
||||||
{
|
{
|
||||||
$result=$mailmanspip->add_to_spip($this);
|
$result=$mailmanspip->add_to_spip($this);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
|
|||||||
@ -3998,14 +3998,13 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if (!empty($this->errors))
|
if (!empty($this->errors))
|
||||||
{
|
{
|
||||||
$this->errors=array_merge($this->errors,$interface->errors);
|
$this->errors=array_unique(array_merge($this->errors,$interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->errors=$interface->errors;
|
$this->errors=$interface->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -191,10 +191,12 @@ class Interfaces
|
|||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
// Action KO
|
// Action KO
|
||||||
|
//dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR);
|
||||||
$nbtotal++;
|
$nbtotal++;
|
||||||
$nbko++;
|
$nbko++;
|
||||||
if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors);
|
if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors);
|
||||||
else if (! empty($objMod->error)) $this->errors[]=$objMod->error;
|
else if (! empty($objMod->error)) $this->errors[]=$objMod->error;
|
||||||
|
//dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -205,7 +207,7 @@ class Interfaces
|
|||||||
|
|
||||||
if ($nbko)
|
if ($nbko)
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_ERR);
|
dol_syslog(get_class($this)."::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko." - Nb of error string returned in this->errors = ".count($this->errors), LOG_ERR);
|
||||||
return -$nbko;
|
return -$nbko;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -54,6 +54,7 @@ $mode = GETPOST('mode','alpha');
|
|||||||
$confirm = GETPOST('confirm','alpha');
|
$confirm = GETPOST('confirm','alpha');
|
||||||
$subaction = GETPOST('subaction','alpha');
|
$subaction = GETPOST('subaction','alpha');
|
||||||
$group = GETPOST("group","int",3);
|
$group = GETPOST("group","int",3);
|
||||||
|
$cancel = GETPOST('cancel');
|
||||||
|
|
||||||
// Define value to know what current user can do on users
|
// Define value to know what current user can do on users
|
||||||
$canadduser=(! empty($user->admin) || $user->rights->user->user->creer);
|
$canadduser=(! empty($user->admin) || $user->rights->user->user->creer);
|
||||||
@ -299,7 +300,8 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'update' && !$_POST["cancel"]) {
|
if ($action == 'update' && ! $cancel)
|
||||||
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
if ($caneditfield) // Case we can edit all field
|
if ($caneditfield) // Case we can edit all field
|
||||||
@ -395,7 +397,7 @@ if (empty($reshook)) {
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
$ret = $object->update($user);
|
$ret = $object->update($user);
|
||||||
if ($ret < 0) {
|
if ($ret < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors');
|
setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors');
|
||||||
|
|||||||
@ -1332,14 +1332,14 @@ class User extends CommonObject
|
|||||||
// If user is linked to a member, remove old link to this member
|
// If user is linked to a member, remove old link to this member
|
||||||
if ($this->fk_member > 0)
|
if ($this->fk_member > 0)
|
||||||
{
|
{
|
||||||
|
dol_syslog(get_class($this)."::update remove link with member. We will recreate it later", LOG_DEBUG);
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member;
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
|
if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
|
||||||
}
|
}
|
||||||
// Set link to user
|
// Set link to user
|
||||||
|
dol_syslog(get_class($this)."::update set link with member", LOG_DEBUG);
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member =".($this->fk_member>0?$this->fk_member:'null')." where rowid = ".$this->id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member =".($this->fk_member>0?$this->fk_member:'null')." where rowid = ".$this->id;
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
|
if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
|
||||||
|
|
||||||
@ -1347,6 +1347,8 @@ class User extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->fk_member > 0 && ! $nosyncmember)
|
if ($this->fk_member > 0 && ! $nosyncmember)
|
||||||
{
|
{
|
||||||
|
dol_syslog(get_class($this)."::update user is linked with a member. We try to update member too.", LOG_DEBUG);
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||||
|
|
||||||
// This user is linked with a member, so we also update members informations
|
// This user is linked with a member, so we also update members informations
|
||||||
@ -1376,14 +1378,16 @@ class User extends CommonObject
|
|||||||
$result=$adh->update($user,0,1);
|
$result=$adh->update($user,0,1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$luser->error;
|
$this->error=$adh->error;
|
||||||
dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR);
|
$this->errors=$adh->errors;
|
||||||
|
dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$adh->error;
|
$this->error=$adh->error;
|
||||||
|
$this->errors=$adh->errors;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user