1

Since around March of this year our osTicket system started posting duplicate tickets and duplicate threads.

I've tried everything method I know of to troubleshoot and identity where and why this is occurring. I've even implemented a catch condition to check the db tables prior to inserting tickets and threads to see if the contents of the $vars[]'s match what is already in the DB tables.

No success to solve this problem whatsoever.

I've Googled it and see where this issue has been in existence and dates back a number of years.

Does any one have a solution on how to stop osTicket from consistently creating ducpliate tickets and threads?

I tried the following from piecing together suggestions others have made out there in the various osTicket up through v1.10. Here is the code I tried. It actually worked for 2-days straight, then began to fail again yesterday.

Inserted around line 2498 in ./include/class.ticket.php right before if($errors) return 0;.

/**
  * J.Doe added to intercept duplicate ticket entries.
  * Updated:   2017-06-12
  * @author    John Doe <jd@example.com>
  */

  $sql1='
    SELECT ticketID FROM ost_ticket
    WHERE
          source      = "' . $vars['source'] . '"
      AND topic_id    = "' . $vars['topicId'] . '"
      AND url         = "' . $vars['url'] . '"
      AND priority_id = "' . $vars['priorityId'] . '"
      AND duedate     = "' . date( 'Y-m-d H:i:s', strtotime( $vars['duedate'] . ' ' . $vars['time'] ) ) . '"
      AND team_id     = "' . $vars['assignId'] . '"
      AND subject     = "' . $vars['subject'] . '"
      AND dept_id     = "' . $vars['deptId'] . '"
      AND email       = "' . $vars['email'] . '"
      AND name        = "' . $vars['name'] . '"
  ';

  $sql2='
    SELECT id FROM ost_ticket_thread
    WHERE
          staff_id = "' . $vars['assignId'] . '"
      AND poster   = "' . $vars['name'] . '"
      AND title    = "' . $vars['subject'] . '"
      AND body     = "' . $vars['message'] . '"
  ';

  $res1=db_query($sql1);
  $res2=db_query($sql2);

  if( ( $res1 && db_num_rows( $res1 ) ) || ( $res2 && db_num_rows( $res2 ) ) ) {
      header( 'Location: http://example.com/workorders/' );
      exit;
  }

        //Any error above is fatal.
        if($errors)  return 0;
frank
  • 11
  • 1

0 Answers0