Skip to content

Commit ec43cef

Browse files
committed
Bugfix: changing Aliasdomain definition from one website to the other, leaves duplicate entries
1 parent 00e5976 commit ec43cef

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

server/plugins-available/apache2_plugin.inc.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,21 @@ function update($event_name,$data) {
186186
if($this->action != 'insert') $this->action = 'update';
187187

188188
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
189+
190+
$old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
191+
$new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
192+
193+
// If the parent_domain_id has been chenged, we will have to update the old site as well.
194+
if($data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
195+
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
196+
$data["new"] = $tmp;
197+
$data["old"] = $tmp;
198+
$this->action = 'update';
199+
$this->update($event_name,$data);
200+
}
201+
189202
// This is not a vhost, so we need to update the parent record instead.
190-
$parent_domain_id = intval($data["new"]["parent_domain_id"]);
191-
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id." AND active = 'y'");
203+
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
192204
$data["new"] = $tmp;
193205
$data["old"] = $tmp;
194206
$this->action = 'update';

0 commit comments

Comments
 (0)