Skip to content

Commit 61a3223

Browse files
committed
Apply mute filter in Certificates::get_expired (fixes phpipam#42)
The $mute_clause was built but never added to the queries, so muted hosts were still included in expiry notifications. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RuhB6rpLgBrF8dpAsSimX9
1 parent 35567c0 commit 61a3223

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎functions/classes/class.Certificates.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ public function get_expired($days = 30, $expired_days = 7, $exclude_muted = fals
111111
$impersonating = isset($_SESSION['impersonate_original']);
112112
$pz_clause = $impersonating ? "and z.private_zone_uid is null" : "and (z.private_zone_uid is null or z.private_zone_uid = ".(int)$this->user->id.")";
113113
// mute filter
114-
$mute_clause = $exclude_muted ? "and h.mute = 0" : "";
114+
$mute_clause = $exclude_muted ? "and (h.mute = 0 or h.id is null)" : "";
115115
// fetch
116116
try {
117117
// keep rows with a current host, plus host-less rows only for manually imported certs
118118
// (a host-less non-manual cert is just a superseded/replaced scan result, not a real orphan)
119119
$orphan_clause = "and (h.id is not null or c.is_manual = 1)";
120120
if ($this->user->admin == "1") {
121-
$certs = $this->Database->getObjectsQuery("select *,c.id as id,z.name as zone_name,z.private_zone_uid as private_zone_uid from certificates as c JOIN zones as z ON c.z_id = z.id JOIN tenants as t ON z.t_id = t.id LEFT JOIN hosts as h ON h.c_id = c.id where c.expires < ? and c.expires > ? $pz_clause $orphan_clause order by expires asc", [$from_date, $expired_from_date]);
121+
$certs = $this->Database->getObjectsQuery("select *,c.id as id,z.name as zone_name,z.private_zone_uid as private_zone_uid from certificates as c JOIN zones as z ON c.z_id = z.id JOIN tenants as t ON z.t_id = t.id LEFT JOIN hosts as h ON h.c_id = c.id where c.expires < ? and c.expires > ? $pz_clause $orphan_clause $mute_clause order by expires asc", [$from_date, $expired_from_date]);
122122
}
123123
else {
124-
$certs = $this->Database->getObjectsQuery("select *,c.id as id,z.name as zone_name,z.private_zone_uid as private_zone_uid from certificates as c JOIN zones as z ON c.z_id = z.id JOIN tenants as t ON z.t_id = t.id LEFT JOIN hosts as h ON h.c_id = c.id where t.id = ? and c.expires < ? and c.expires > ? $pz_clause $orphan_clause order by expires asc", [$this->user->t_id, $from_date, $expired_from_date]);
124+
$certs = $this->Database->getObjectsQuery("select *,c.id as id,z.name as zone_name,z.private_zone_uid as private_zone_uid from certificates as c JOIN zones as z ON c.z_id = z.id JOIN tenants as t ON z.t_id = t.id LEFT JOIN hosts as h ON h.c_id = c.id where t.id = ? and c.expires < ? and c.expires > ? $pz_clause $orphan_clause $mute_clause order by expires asc", [$this->user->t_id, $from_date, $expired_from_date]);
125125
}
126126
}
127127
catch (Exception $e) {

0 commit comments

Comments
 (0)