diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index e3a60fbf6ab..1eb3ec15f9f 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -1324,10 +1324,10 @@ class FormMail extends Form
$sql .= " AND (lang = '".$dbs->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$dbs->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')";
}
if ($id > 0) {
- $sql .= " AND rowid=".(int) $id;
+ $sql .= " AND rowid = ".(int) $id;
}
if ($id == -1) {
- $sql .= " AND position=0";
+ $sql .= " AND position = 0";
}
if ($languagetosearch) {
$sql .= $dbs->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php
index f037f26176c..1bec1c5c67e 100644
--- a/htdocs/core/modules/modEventOrganization.class.php
+++ b/htdocs/core/modules/modEventOrganization.class.php
@@ -375,6 +375,11 @@ class modEventOrganization extends DolibarrModules
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($this->db);
+ include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
+ if (!is_object($user)) {
+ $user = new User($this->db); // To avoid error during migration
+ }
+
$template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskConf)');
if ($template->id > 0) {
dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF', $template->id, 'chaine', 0, '', $conf->entity);