FIX Missing include of ActionComm in doAutoRenewContracts (#39387)

Contrat::doAutoRenewContracts() instantiates ActionComm to log the
RENEW_CONTRACT event, but contrat.class.php never loads
comm/action/class/actioncomm.class.php.

From a web request the class is usually already loaded by some other
include, so the problem stays hidden. When the method is run as a
scheduled job it is not: scripts/cron/cron_run_jobs.php loads only
master.inc.php, functionscli.lib.php, cronjob.class.php and
user.class.php, and cronjob.class.php then loads only the job class
itself via dol_include_once($this->classesname). ActionComm is not part
of that include closure, so the method fails with
"Class ActionComm not found".

The fatal error happens after the UPDATE on llx_contratdet has been
issued but before $this->db->commit(), so the transaction is never
committed and the renewal is lost. The job also aborts, so every
remaining contract line in the loop is left unprocessed and the failure
is only visible as a fatal error in the log.

Verified on 23.0.3: after the cron bootstrap, class_exists('Contrat')
is true while class_exists('ActionComm') is false. Adding the include
next to the existing html.formmail.class.php include makes it true.

Signed-off-by: Florian Hödl <florian@hoedl.co>
Co-authored-by: Florian Hödl <florian@hoedl.co>
This commit is contained in:
Florian Hödl 2026-08-05 10:18:26 +02:00 committed by GitHub
parent 6dfc8de4b5
commit 72ecff38e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2753,6 +2753,7 @@ class Contrat extends CommonObject
$num = $this->db->num_rows($resql);
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$i = 0;
while ($i < $num) {