When we try to search tickets with no attachments, we get this error:
[SELECT COUNT(*) FROM (SELECT A1.ticket_id
FROM ost_ticket
A1 JOIN ost_ticket_status
A2 ON (A1.status_id
= A2.id
) JOIN ost_form_entry
A3 ON (A3.object_type
= 'T' AND A1.ticket_id
= A3.object_id
) JOIN ost_form_entry_values
A4 ON (A3.id
= A4.entry_id
AND A4.field_id
= 191) WHERE NOT A2.id
IN (3, 31) AND A1.topic_id
= 12 AND NOT A4.value
IS NOT NULL AND A1.attachment_count
= 0) __]
Unknown column 'A1.attachment_count' in 'where clause'<br /> <br />
---- Trace back ----<br />
#0 (Root) source/include/mysqli.php(211): osTicket->logDBError('DB Error #1054', '[SELECT COUNT(...')<br />
#1 (Root) source/include/class.orm.php(3482): db_query('SELECT COUNT()...', true, true)<br />
#2 (Root) source/include/class.orm.php(3538): MySqlExecutor->execute()<br />
#3 (Root) source/include/class.orm.php(2964): MySqlExecutor->getRow()<br />
#4 (Root) source/include/class.orm.php(1381): MySqlCompiler->compileCount(Object(QuerySet))<br />
#5 (Root) source/include/class.search.php(910): QuerySet->count()<br />
#6 (Root) source/include/class.search.php(1010): SavedQueue->getTotal()<br />
#7 (Root) source/scp/autocron.php(43): SavedQueue::counts(Object(StaffSession), false)<br />
#8 {main}
Tested with: osTicket v1.18 (724de45)
Apache/2.4.57 (Unix)
MariaDB 10.3.37
PHP 8.2.5