Fix error management when renaming a project with existing ref.

This commit is contained in:
Laurent Destailleur 2017-03-02 20:06:10 +01:00
parent 5842d1ee41
commit e6846f5c01
2 changed files with 16 additions and 8 deletions

View File

@ -270,8 +270,9 @@ if (empty($reshook))
$result=$object->update($user);
if ($result < 0)
{
$error++;
setEventMessages($object->error, $object->errors,'errors');
$error++;
if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors');
else setEventMessages($object->error, $object->errors, 'errors');
}else {
// Category association
$categories = GETPOST('categories');

View File

@ -334,12 +334,19 @@ class Project extends CommonObject
}
else
{
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
$this->db->rollback();
dol_syslog(get_class($this)."::update error -2 " . $this->error, LOG_ERR);
$result = -2;
}
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
$this->db->rollback();
if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$result = -4;
}
else
{
$result = -2;
}
dol_syslog(get_class($this)."::update error " . $result . " " . $this->error, LOG_ERR);
}
}
else
{