Installed support system - ticket details not accessible

When I go to create a ticket within the Support System plugin, I get the following error:

Ticket Error: There was an error submitting your ticket. Please try again in a few minutes.

I can see the list of tickets that were submitted where I got the above error, but I cannot see the ticket details. When I click on the ticket, it gives me an error message that says:

The ticket you're trying to find does not exist.

I am running this support system on a Multi-site configuration, but I didn't know if that matters. The Support System plugin is network activated and I'm using version 1.9.9.1

  • Rahul Verma

    Hi @Foster,

    Sorry for late response.

    I have tested Support System Version 1.9.9.1 on both single and multisite installation. and It's working perfectly for create a new ticket or update.

    Your settings are perfect as well but somehow insertions is not being completed according to error message you mentioned.

    Please send me the FTP credentials of your site through our contact form: https://premium.wpmudev.org/contact/

    - Choose "I have a different question"
    - Include my name in the subject "Sandeep Kumar"
    - Include the URL of this post in your message so that I may track this issue better
    - Include any relevant login information (Wordpress admin info username + password )
    - Include FTP Details

    Best Regards,
    Sandeep Kumar

    • Foster

      Sandeep, Unfortunately I don't have extra permissions I can extend to individuals outside of our network. I guess I'm confused as the database tables don't appear to have all the information.

      Can you please explain where the message content is stored in the database?

      Since I cannot give you FTP access, can you please let me know what you would look for and test for as I can do the testing myself?

      I am not sure what to do at this point as the delete routine doesn't delete the database tables and again, I'm unclear on where the Support System plugin is storing the ticket message field and any upload related content.

      I can do a screensharing review with you or one of the other support team members.

      Please let me know how to move forward. Thanks.

  • Rahul Verma

    Hello,

    Thank you for posting back.

    About Table Structure, please take a look on table_support_tickets.png. These are tables where all data is being saved.

    I can see the list of tickets that were submitted where I got the above error,

    You can see all of these tickets data in wp_support_tickets table.

    but I cannot see the ticket details.

    Ticket details are being saved in wp_support_tickets_messages which is not happening in your case.

    Can you please take a look on these tables and let me know if you can see your saved data?

    Further investigation, If you don't see your data in "wp_support_tickets_messages", take a look in "add_new_ticket" function on line 618 in /wp-content/plugins/incsub-support/model/model.php and debug there if all queries are being executed correctly. Below is a debug version of this function which helps you to see error message or some debug messages.

    Before :

    public function add_new_ticket( $ticket_details ) {
    			global $wpdb, $current_site;
    
    			$current_site_id = ! empty ( $current_site ) ? $current_site->id : 1;
    
    			$attachments = !empty( $ticket_details['attachments'] ) ? $ticket_details['attachments'] : array();
    			$time = current_time( 'mysql', 1 );
    			$wpdb->query(
    				$wpdb->prepare(
    					"INSERT INTO $this->tickets_table
    					(site_id, blog_id, cat_id, user_id, ticket_priority, ticket_opened, ticket_updated, title, admin_id)
    					VALUES ( '%d', '%d', '%d', '%d', '%d', %s, %s, '%s', %d )",
    					$current_site_id,
    					get_current_blog_id(),
    					$ticket_details['cat_id'],
    					get_current_user_id(),
    					$ticket_details['ticket_priority'],
    					$time,
    					$time,
    					$ticket_details['subject'],
    					$ticket_details['admin_id']
    				)
    			);
    
    			if ( ! $wpdb->insert_id )
    				return false;
    
    			$ticket_id = $wpdb->insert_id;
    			$wpdb->query(
    				$wpdb->prepare(
    					"INSERT INTO $this->tickets_messages_table
    					(site_id, ticket_id, user_id, subject, message, message_date, attachments)
    					VALUES (
    						'%d', '%d', '%d', '%s', '%s', '%s', '%s'
    					)",
    					$current_site_id,
    					$wpdb->insert_id,
    					get_current_user_id(),
    					$ticket_details['subject'],
    					$ticket_details['message'],
    					$time,
    					maybe_serialize( $attachments )
    				)
    			);
    
    			if ( ! $wpdb->insert_id )
    				return false;
    			else
    				return $ticket_id;
    
    		}

    After :

    public function add_new_ticket( $ticket_details ) {
    			global $wpdb, $current_site;
    
    			$current_site_id = ! empty ( $current_site ) ? $current_site->id : 1;
    
    			$attachments = !empty( $ticket_details['attachments'] ) ? $ticket_details['attachments'] : array();
    			$time = current_time( 'mysql', 1 );
    			//Show Mysql Error
    			$wpdb->show_errors();
    			$wpdb->query(
    				$wpdb->prepare(
    					"INSERT INTO $this->tickets_table
    					(site_id, blog_id, cat_id, user_id, ticket_priority, ticket_opened, ticket_updated, title, admin_id)
    					VALUES ( '%d', '%d', '%d', '%d', '%d', %s, %s, '%s', %d )",
    					$current_site_id,
    					get_current_blog_id(),
    					$ticket_details['cat_id'],
    					get_current_user_id(),
    					$ticket_details['ticket_priority'],
    					$time,
    					$time,
    					$ticket_details['subject'],
    					$ticket_details['admin_id']
    				)
    			);
    
    			// it seems $wpdb->insert_id is not being generated and further scripts not executed.
    			if ( ! $wpdb->insert_id )
    				{
    					die("Something is wrong in creating ticket.");
    					return false;
    				}
    				else
    				{
    					echo "Ticekt ID is ".$wpdb->insert_id;
    
    					}
    
    			$ticket_id = $wpdb->insert_id;
    			$wpdb->query(
    				$wpdb->prepare(
    					"INSERT INTO $this->tickets_messages_table
    					(site_id, ticket_id, user_id, subject, message, message_date, attachments)
    					VALUES (
    						'%d', '%d', '%d', '%s', '%s', '%s', '%s'
    					)",
    					$current_site_id,
    					$wpdb->insert_id,
    					get_current_user_id(),
    					$ticket_details['subject'],
    					$ticket_details['message'],
    					$time,
    					maybe_serialize( $attachments )
    				)
    			);
    
    			if ( ! $wpdb->insert_id )
    				{
    				     die("Something is wrong in creating ticket details.");
    					return false;
    				}
    			else
    				{
    					return $ticket_id;
    				}
    		}

    Please let me know output of this new function.

    Best Regards
    Sandeep Kumar

  • Rahul Verma

    Hello @Foster,

    Thanks for checking it with me.

    There are two ways to create missing table.

    Via PHPMYADMIN - You can execute following mysql query to create table manually. Make your change the prefix of the table as per your wordpress installation.

    CREATE TABLE IF NOT EXISTS wp_support_tickets_messages (
      message_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      site_id bigint(20) unsigned NOT NULL,
      ticket_id bigint(20) unsigned NOT NULL,
      user_id bigint(20) unsigned NOT NULL,
      admin_id bigint(20) unsigned NOT NULL,
      message_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      subject varchar(255) NOT NULL,
      message mediumtext NOT NULL,
      attachments text,
      PRIMARY KEY (message_id),
      KEY ticket_id (ticket_id)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

    Via Plugin Activation : You can deactivate the plugin and activate it again. In this process, You'll not lost your existing data.

    I hope that helps. Please feel free to ask if you have more questions on the same.

    Best Regards
    Sandeep Kumar

  • Foster

    I have created the table and ran through the debug option. The output after trying to create a ticket is the following:

    "Ticekt ID is 8Something is wrong in creating ticket details."

    Please let me know if that helps with anything. At this point, the database has the "wp_support_tickets_messages" table but there isn't any content being inserted in. Records are being created in the other tables, but not with this table.

    Please let me know what needs to be done next in regards to testing / debugging.

    Thanks.

  • Rahul Verma

    Hello,

    Now we're going to display mysql query which is going failed.

    Please make a change in model/model.php on line 658 as per following snippet code.

    Before :

    $wpdb->query(
    				$wpdb->prepare(
    					"INSERT INTO $this->tickets_messages_table
    					(site_id, ticket_id1, user_id, subject, message, message_date, attachments)
    					VALUES (
    						'%d', '%d', '%d', '%s', '%s', '%s', '%s'
    					)",
    					$current_site_id,
    					$wpdb->insert_id,
    					get_current_user_id(),
    					$ticket_details['subject'],
    					$ticket_details['message'],
    					$time,
    					maybe_serialize( $attachments )
    				)
    			);

    After :

    $wpdb->query(
    				$wpdb->prepare(
    					"INSERT INTO $this->tickets_messages_table
    					(site_id, ticket_id1, user_id, subject, message, message_date, attachments)
    					VALUES (
    						'%d', '%d', '%d', '%s', '%s', '%s', '%s'
    					)",
    					$current_site_id,
    					$wpdb->insert_id,
    					get_current_user_id(),
    					$ticket_details['subject'],
    					$ticket_details['message'],
    					$time,
    					maybe_serialize( $attachments )
    				)
    			) or die($wpdb->last_query);

    Now when you'll create a new ticket, You'll see a blank screen with a mysql query. Please run that mysql query in phpmyadmin or give me so I can run it myself to see the error.

    Thanks

  • Rahul Verma

    Hello,

    Please update the following function in model/model.php on line 181. After that, Please deactivate and then activate the plugin.

    Before :

    private function create_tickets_messages_table() {
    
    			global $wpdb;
    
    			$sql = "CREATE TABLE $this->tickets_messages_table (
    				message_id bigint(20) unsigned NOT NULL auto_increment,
    				site_id bigint(20) unsigned NOT NULL,
    				ticket_id bigint(20) unsigned NOT NULL,
    				user_id bigint(20) unsigned NOT NULL,
    				admin_id bigint(20) unsigned NOT NULL,
    				message_date timestamp NOT NULL default CURRENT_TIMESTAMP,
    				subject varchar(255) character set utf8 NOT NULL,
    				message mediumtext character set utf8 NOT NULL,
    				attachments text DEFAULT '',
    				PRIMARY KEY  (message_id),
    				KEY ticket_id (ticket_id)
    			      ) ENGINE=MyISAM $this->db_charset_collate;";
    
    			dbDelta($sql);
    
    		}

    After :

    private function create_tickets_messages_table() {
    
    			global $wpdb;
    
    			$sql = "CREATE TABLE $this->tickets_messages_table (
    				message_id bigint(20) unsigned NOT NULL auto_increment,
    				site_id bigint(20) unsigned NOT NULL,
    				ticket_id bigint(20) unsigned NOT NULL,
    				user_id bigint(20) unsigned NOT NULL,
    				admin_id bigint(20) unsigned DEFAULT NULL,
    				message_date timestamp NOT NULL default CURRENT_TIMESTAMP,
    				subject varchar(255) character set utf8 NOT NULL,
    				message mediumtext character set utf8 NOT NULL,
    				attachments text DEFAULT '',
    				PRIMARY KEY  (message_id),
    				KEY ticket_id (ticket_id)
    			      ) ENGINE=MyISAM $this->db_charset_collate;";
    
    			dbDelta($sql);
    
    		}

    Please let me know if still you get any error.

    Best Regards
    Sandeep Kumar