Skip to content

Instantly share code, notes, and snippets.

@mikesname
Last active August 2, 2021 10:59
Show Gist options
  • Save mikesname/38470e10de9e3afec485b8379381e8c9 to your computer and use it in GitHub Desktop.
Save mikesname/38470e10de9e3afec485b8379381e8c9 to your computer and use it in GitHub Desktop.
OSTicket no thread displayed...

OSTicket Duplicate email debugging

Problem:

  • Threads not being show when opening ticket
  • No JS or other apparent UI errors

Error in Apache logs:

PHP Fatal error:  Uncaught ObjectNotUnique: One object was expected; however multiple objects in the database matched the query. In fact, there are 2 matching objects. in /var/www/helpdesk.ehri-project.eu/include/class.orm.php:1364

Stack trace:

#0 /var/www/helpdesk.ehri-project.eu/include/class.orm.php(607): QuerySet->one()
#1 /var/www/helpdesk.ehri-project.eu/include/staff/templates/thread-entries.tmpl.php(37): VerySimpleModel::lookup(Array)
#2 /var/www/helpdesk.ehri-project.eu/include/class.thread.php(408): include('/var/www/helpde...')
#3 /var/www/helpdesk.ehri-project.eu/include/staff/ticket-view.inc.php(759): Thread->render(Array, Array)
#4 /var/www/helpdesk.ehri-project.eu/scp/tickets.php(539): require_once('/var/www/helpde...')
#5 {main}\n  thrown in /var/www/helpdesk.ehri-project.eu/include/class.orm.php on line 1364', referer: https://helpdesk.ehri-project.eu/scp/tickets.php?id=5714

Current workaround derived from here:

https://forum.osticket.com/d/97956-cant-see-ticket-content

Query to detect duplicate emails:

SELECT 
    thread_entry_id, 
    COUNT(thread_entry_id)
FROM
    ost_thread_entry_email
GROUP BY thread_entry_id
HAVING COUNT(thread_entry_id) > 1;

Back up the existing table:

CREATE TABLE ost_thread_entry_email_backup 
SELECT * 
FROM
    ost_thread_entry_email;

Delete duplicates:

DELETE t1 FROM ost_thread_entry_email t1
INNER JOIN ost_thread_entry_email t2 
WHERE 
    t1.id < t2.id AND 
    t1.thread_entry_id = t2.thread_entry_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment