Skip to content

Commit

Permalink
fix: correct SQLite backend problem preventing zone updates from temp…
Browse files Browse the repository at this point in the history
…late page, closes #538
  • Loading branch information
edmondas committed Dec 17, 2023
1 parent 1adfd35 commit 828dcdd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/DnsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ public function get_zones(string $perm, int $userid = 0, string $letterstart = '
$this->db->setLimit($rowamount, $rowstart);
}
$result = $this->db->query($query);
$this->db->setLimit(0);

$ret = array();
while ($r = $result->fetch()) {
Expand Down Expand Up @@ -1311,6 +1312,7 @@ public static function get_records_from_domain_id($db, $db_type, int $id, int $r
FROM records
WHERE domain_id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL
ORDER BY type = 'SOA' DESC, type = 'NS' DESC," . $sql_sortby);
$db->setLimit(0);

if ($records) {
$result = $records->fetchAll();
Expand Down Expand Up @@ -1629,6 +1631,8 @@ public function update_zone_records($db_type, $dns_ttl, int $zone_id, int $zone_
if ($perm_edit == "all" || ($perm_edit == "own" && $user_is_zone_owner == "1")) {
if ($db_type == 'pgsql') {
$query = "DELETE FROM records r USING records_zone_templ rzt WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id AND r.id = rzt.record_id";
} else if ($db_type == 'sqlite' || $db_type == 'sqlite3') {
$query = "DELETE FROM records WHERE id IN (SELECT r.id FROM records r LEFT JOIN records_zone_templ rzt ON r.id = rzt.record_id WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id)";
} else {
$query = "DELETE r, rzt FROM records r LEFT JOIN records_zone_templ rzt ON r.id = rzt.record_id WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id";
}
Expand Down Expand Up @@ -1681,7 +1685,6 @@ public function update_zone_records($db_type, $dns_ttl, int $zone_id, int $zone_
$record_id = $this->db->lastInsertId();
}

$this->db->setLimit(0);
$query = "INSERT INTO records_zone_templ (domain_id, record_id, zone_templ_id) VALUES ("
. $this->db->quote($zone_id, 'integer') . ","
. $this->db->quote($record_id, 'integer') . ","
Expand Down
2 changes: 2 additions & 0 deletions lib/LegacyUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public static function show_users($db, int|string $id = '', int $rowstart = 0, i
// Execute the huge query.
$db->setLimit($rowamount, $rowstart);
$response = $db->query($query);
$db->setLimit(0);

$ret = array();
while ($r = $response->fetch()) {
$ret [] = array(
Expand Down
1 change: 1 addition & 0 deletions lib/ZoneTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public static function get_zone_templ_records($db, int $id, int $rowstart = 0, i

$stmt = $db->prepare("SELECT id FROM zone_templ_records WHERE zone_templ_id = :id ORDER BY " . $sortby);
$stmt->execute([':id' => $id]);
$db->setLimit(0);

$ret[] = array();
$retCount = 0;
Expand Down

0 comments on commit 828dcdd

Please sign in to comment.