mail_domain_add() with api - fires mail_mail_domain_edit with event where a "new domain" case check is missing on user/spamlist update
On line 63 of mail_mail_domain_plugin.inc.php the code checks if there is domain name change or owner change for mailbox/spamfilter update.
It checks if oldDataRecord exists but this record exists on mail_domain_add() too (empty but exists) and oldDataRecord['domain'] != $domain is true too (because oldDataRecord['domain'] is empty/undef) - so the code get executed. I am not sure if it update anything because mostly search for email %@olddomain and olddomain ist empty but think it is better to check if oldDataRecord['domain'] exists
diff --git a/interface/lib/plugins/mail_mail_domain_plugin.inc.php b/interface/lib/plugins/mail_mail_domain_plugin.inc.php
--- a/interface/lib/plugins/mail_mail_domain_plugin.inc.php
+++ b/interface/lib/plugins/mail_mail_domain_plugin.inc.php (date 1711013653411)
@@ -60,7 +60,7 @@
}
//** If the domain name or owner has been changed, change the domain and owner in all mailbox records
- if($page_form->oldDataRecord && ($page_form->oldDataRecord['domain'] != $domain ||
+ if($page_form->oldDataRecord && !empty($page_form->oldDataRecord['domain']) && ($page_form->oldDataRecord['domain'] != $domain ||
(isset($page_form->dataRecord['client_group_id']) && $page_form->oldDataRecord['sys_groupid'] != $page_form->dataRecord['client_group_id']))) {
$app->uses('getconf');
$mail_config = $app->getconf->get_server_config($page_form->dataRecord["server_id"], 'mail');
Edited by Hannes