Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging tickets causes duplicate records and fatal error. #5379

Open
Mike-Benoit opened this issue Feb 16, 2020 · 6 comments
Open

Merging tickets causes duplicate records and fatal error. #5379

Mike-Benoit opened this issue Feb 16, 2020 · 6 comments
Labels

Comments

@Mike-Benoit
Copy link

Prerequisites

  • [Yes] Can you reproduce the problem in a fresh installation of the "develop" branch?
  • [Yes] Do you have any errors in the PHP error log, or javascript console?
  • [Yes] Did you check the osTicket forums?
  • [Yes] Did you perform a cursory search to see if your bug or enhancement is already reported?

Description

When merging tickets in a certain situation/order, the following error message can occur when viewing the merged ticket, making it impossible to ever view again without manual intervention in the database.

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/osticket/include/class.orm.php:1363
Stack trace: #0 /var/www/osticket/include/class.orm.php(606): QuerySet->one()
#1 /var/www/osticket/include/class.orm.php(381): VerySimpleModel::lookup(Array)
#2 /var/www/osticket/include/class.orm.php(801): VerySimpleModel->get('merge_info')
#3 /var/www/osticket/include/class.orm.php(417): AnnotatedModel___ThreadEntry->get('merge_info', NULL)
#4 /var/www/osticket/include/class.thread.php(1576): VerySimpleModel->__get('merge_info')
#5 /var/www/osticket/include/class.thread.php(1584): ThreadEntry->getMergeData()
#6 /var/www/osticket/include/staff/templates/thread-entries.tmpl.php(33): ThreadEntry::sortEntries(Object(QuerySet), Object(Ticket))
#7 /var/www/osticket/include/class.thread.php(408): in /var/www/osticket/include/class.orm.php on line 1363

I believe this is also related to the merge issue described here: https://forum.osticket.com/d/96658-can-t-view-new-tickets-after-upgrade-to-v1-14-1/7

Steps to Reproduce

This is fairly long, but essentially it involves sending four emails to osTicket, merging two into group 1, and two into group 2, then merging group 1 into group 2.

Here are the steps in detail:

Create Group 1 tickets:

  1. Send email to osTicket with subject/body of: "Parent 1"

  2. Send email to osTicket with subject/body of: "Parent 1 (child1)"
    Open this ticket, copy its Ticket number.

  3. Go to Parent 1 ticket:
    Click More > Merge Tickets
    Click Select Ticket field
    Paste Ticket Number from above "Parent 1 (child1)" ticket.
    Click the child's number that appears (not the name, apparently clicking the name causes other problems)
    Click Add ticket
    Check Delete Child Ticket
    Click Save changes

Create Group 2 tickets:

  1. Send email to osTicket with subject/body of: "Parent 2"

  2. Send email to osTicket with subject/body of: "Parent 2 (child1)"
    Open this ticket, copy its Ticket number.

  3. Open Parent 2
    Click More > Merge Tickets
    Click Select Ticket field
    Paste Ticket Number from above "Parent 2 (child1)" ticket.
    Click the child's number that appears (not the name)
    Click Add ticket
    Check Delete Child Ticket
    Click Save changes

Now merge both groups of tickets into one:

  1. Go to Parent 2 ticket:
    Click More > Merge Tickets
    Click Select Ticket field
    Paste Ticket Number from above "Parent 1" ticket.
    Click the child's number that appears (not the name)
    Click Add ticket
    Check Delete Child Ticket
    Click Save changes

The above error message should appear as soon as you save the changes and it refreshes Parent 2 ticket on the screen.

Versions

v1.14-git on Ubuntu 18.04

@JediKev
Copy link
Contributor

JediKev commented Mar 9, 2020

@Mike-Benoit

I can replicate the same issues with latest develop-next. We will look into this.

Cheers.

@JediKev JediKev added the bug label Mar 9, 2020
aydreeihn added a commit to aydreeihn/osTicket that referenced this issue Mar 19, 2020
This commit fixes an issue we had with creating duplicate records in the thread_entry_merge table. This would happen if you were to merge tickets, deleting the child tickets, and then try to merge that ticket into another ticket.

This fixes Issue osTicket#5379.
@JediKev
Copy link
Contributor

JediKev commented Mar 23, 2020

@Mike-Benoit

This is addressed with:

Cheers.

@Mike-Benoit
Copy link
Author

I can confirm #5425 this fixes this bug, greatly appreciated!

@inphower
Copy link

inphower commented Apr 6, 2020

Prerequisites

  • [Yes] Can you reproduce the problem in a fresh installation of the "develop" branch?
  • [Yes] Do you have any errors in the PHP error log, or javascript console?
  • [Yes] Did you check the osTicket forums?
  • [Yes] Did you perform a cursory search to see if your bug or enhancement is already reported?

Description

When merging tickets in a certain situation/order, the following error message can occur when viewing the merged ticket, making it impossible to ever view again without manual intervention in the database.

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/osticket/include/class.orm.php:1363
Stack trace: #0 /var/www/osticket/include/class.orm.php(606): QuerySet->one()
#1 /var/www/osticket/include/class.orm.php(381): VerySimpleModel::lookup(Array)
#2 /var/www/osticket/include/class.orm.php(801): VerySimpleModel->get('merge_info')
#3 /var/www/osticket/include/class.orm.php(417): AnnotatedModel___ThreadEntry->get('merge_info', NULL)
#4 /var/www/osticket/include/class.thread.php(1576): VerySimpleModel->__get('merge_info')
#5 /var/www/osticket/include/class.thread.php(1584): ThreadEntry->getMergeData()
#6 /var/www/osticket/include/staff/templates/thread-entries.tmpl.php(33): ThreadEntry::sortEntries(Object(QuerySet), Object(Ticket))
#7 /var/www/osticket/include/class.thread.php(408): in /var/www/osticket/include/class.orm.php on line 1363

I believe this is also related to the merge issue described here: https://forum.osticket.com/d/96658-can-t-view-new-tickets-after-upgrade-to-v1-14-1/7

Steps to Reproduce

This is fairly long, but essentially it involves sending four emails to osTicket, merging two into group 1, and two into group 2, then merging group 1 into group 2.

Here are the steps in detail:

Create Group 1 tickets:

  1. Send email to osTicket with subject/body of: "Parent 1"
  2. Send email to osTicket with subject/body of: "Parent 1 (child1)"
    Open this ticket, copy its Ticket number.
  3. Go to Parent 1 ticket:
    Click More > Merge Tickets
    Click Select Ticket field
    Paste Ticket Number from above "Parent 1 (child1)" ticket.
    Click the child's number that appears (not the name, apparently clicking the name causes other problems)
    Click Add ticket
    Check Delete Child Ticket
    Click Save changes

Create Group 2 tickets:

  1. Send email to osTicket with subject/body of: "Parent 2"
  2. Send email to osTicket with subject/body of: "Parent 2 (child1)"
    Open this ticket, copy its Ticket number.
  3. Open Parent 2
    Click More > Merge Tickets
    Click Select Ticket field
    Paste Ticket Number from above "Parent 2 (child1)" ticket.
    Click the child's number that appears (not the name)
    Click Add ticket
    Check Delete Child Ticket
    Click Save changes

Now merge both groups of tickets into one:

  1. Go to Parent 2 ticket:
    Click More > Merge Tickets
    Click Select Ticket field
    Paste Ticket Number from above "Parent 1" ticket.
    Click the child's number that appears (not the name)
    Click Add ticket
    Check Delete Child Ticket
    Click Save changes

The above error message should appear as soon as you save the changes and it refreshes Parent 2 ticket on the screen.

Versions

v1.14-git on Ubuntu 18.04

Hi, I have a merged tickets with this problem and content disappear , how i can resolve the Duplicate?? .. I have patched for avoid future problems.

Thanks!

@JediKev
Copy link
Contributor

JediKev commented Apr 6, 2020

@inphower

You need to find the duplicate record in the ost_thread_entry_merge table and either modify it or delete it altogether.

Cheers.

@inphower
Copy link

inphower commented Apr 6, 2020 via email

aydreeihn added a commit to aydreeihn/osTicket that referenced this issue Apr 22, 2020
This commit fixes an issue we had with creating duplicate records in the thread_entry_merge table. This would happen if you were to merge tickets, deleting the child tickets, and then try to merge that ticket into another ticket.

This fixes Issue osTicket#5379.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants