Fix regression in cron jobs
This commit is contained in:
parent
a3493d0132
commit
c171ba3a45
@ -167,15 +167,16 @@ class Conf
|
||||
* Load setup values into conf object (read llx_const) for a specified entity
|
||||
* Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called.
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param int $entity Entity to get
|
||||
* @return int < 0 if KO, >= 0 if OK
|
||||
*/
|
||||
public function setEntityValues($entity)
|
||||
public function setEntityValues($db, $entity)
|
||||
{
|
||||
if ($this->entity != $entity) {
|
||||
// If we ask to reload setup for a new entity
|
||||
$this->entity = $entity;
|
||||
return $this->setValues($this->db);
|
||||
return $this->setValues($db);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1081,7 +1081,7 @@ class Cronjob extends CommonObject
|
||||
dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING);
|
||||
}
|
||||
$savcurrententity = $conf->entity;
|
||||
$conf->setEntityValues($this->entity);
|
||||
$conf->setEntityValues($this->db, $this->entity);
|
||||
dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
@ -1090,13 +1090,13 @@ class Cronjob extends CommonObject
|
||||
if ($result < 0) {
|
||||
$this->error = "User Error:".$user->error;
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return -1;
|
||||
} else {
|
||||
if (empty($user->id)) {
|
||||
$this->error = " User user login:".$userlogin." do not exists";
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1126,7 +1126,7 @@ class Cronjob extends CommonObject
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result < 0) {
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1241,7 +1241,7 @@ class Cronjob extends CommonObject
|
||||
if ($ret === false) {
|
||||
$this->error = $langs->trans('CronCannotLoadLib').': '.$libpath;
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1250,7 +1250,7 @@ class Cronjob extends CommonObject
|
||||
$result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing
|
||||
if ($result < 0) { // If technical error
|
||||
dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1316,11 +1316,11 @@ class Cronjob extends CommonObject
|
||||
$result = $this->update($user); // This include begin/commit
|
||||
if ($result < 0) {
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$conf->setEntityValues($savcurrententity);
|
||||
$conf->setEntityValues($this->db, $savcurrententity);
|
||||
return $error ?-1 : 1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user