Skip to content

Instantly share code, notes, and snippets.

@mikesname
Last active August 2, 2021 10:59
Show Gist options
  • Select an option

  • Save mikesname/38470e10de9e3afec485b8379381e8c9 to your computer and use it in GitHub Desktop.

Select an option

Save mikesname/38470e10de9e3afec485b8379381e8c9 to your computer and use it in GitHub Desktop.

Revisions

  1. mikesname renamed this gist Aug 2, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. mikesname revised this gist Aug 2, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ Problem:

    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
    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:

  3. mikesname revised this gist Aug 2, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ 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...')
  4. mikesname renamed this gist Aug 2, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. mikesname created this gist Aug 2, 2021.
    56 changes: 56 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    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:

    ```sql
    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:

    ```sql
    CREATE TABLE ost_thread_entry_email_backup
    SELECT *
    FROM
    ost_thread_entry_email;
    ```


    Delete duplicates:

    ```sql
    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;
    ```