BUGFIX: osTicket 1.8.1 – Opening tickets via email fails

Recently a lot of people who have upgraded to 1.8.1rc1 or 1.8.1ST have reported getting an error when an existing user (client) tries to open a ticket via email. Due to a small coding error the user_id is being stored as 0. This results in a screen that looks like:

And results in a PHP error of: Fatal error: Call to a member function getPhoneNumber() on a non-object in path\to\include\class.ticket.php on line 311.

This error is due to a problem when saving the user_id to the database for the new ticket. Here's how you fix it. edit include/class.ticket.php locate line 2287:

             .' ,user_id='.db_input($user->id)

change it to:

             .' ,user_id='.db_input($user->getId())

This will allow the system to properly save the user_id as it should. This change has already been applied to the github repository and future versions should not have this issue.

This change will not however fix existing tickets. To fix existing tickets you will either have to re-parse the emails, or manually alter the database. To manually alter your database (either via MySQL CLI or 3rd party MySQL GUI) you will need to identify who tried to open the ticket (email address) and look up their user_id in the database.  Here is the process:

  • Look up the email address (address column) in the ost_user_email table and note their user_id.
  • Open the ost_ticket table and find the ticket # of the broken ticket. 
  • Insert the user_id into the user_id column for that ticket.  

If you have multiple or a lot of tickets that are broken it is probably best that you reparse the original emails.