Skip to content

Commit 0d31bd4

Browse files
committed
Fix snooze service: query ticket_meta directly instead of SHOW TABLES LIKE check
1 parent f33ff07 commit 0d31bd4

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

includes/Services/TicketSnoozeService.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,16 @@ public static function get_snoozed_ticket_ids(): array
167167
global $wpdb;
168168
$table = Escalated::table('ticket_meta');
169169

170-
// Check if table exists first.
171-
$table_exists = $wpdb->get_var(
172-
$wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table))
173-
);
174-
if (! $table_exists) {
175-
return [];
176-
}
177-
170+
// Suppress errors for the query in case table doesn't exist yet.
171+
$suppress = $wpdb->suppress_errors();
178172
$rows = $wpdb->get_results(
179173
"SELECT ticket_id FROM {$table} WHERE meta_key = 'snoozed_until'"
180174
);
175+
$wpdb->suppress_errors($suppress);
176+
177+
if ($wpdb->last_error) {
178+
return [];
179+
}
181180

182181
return array_map(fn ($row) => (int) $row->ticket_id, $rows ?: []);
183182
}

0 commit comments

Comments
 (0)