Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

DB Error #1062

[INSERT INTO `ost_attachment` SET `file_id` = 9466, `type` = 'D', `object_id` = 555]

Duplicate entry '555-9466-D' for key 'file-type'<br /> <br />
---- Backtrace ----<br />
#0 (root)/include/mysqli.php(204): osTicket->logDBError('DB Error #1062', '[INSERT INTO `o...')<br />
#1 (root)/include/class.orm.php(3133): db_query('INSERT INTO `os...', true, true)<br />
#2 (root)/include/class.orm.php(597): MySqlExecutor->execute()<br />
#3 (root)/include/class.attachment.php(161): VerySimpleModel->save()<br />
#4 (root)/include/ajax.draft.php(101): GenericAttachments->upload(Array)<br />
#5 (root)/include/ajax.draft.php(300): DraftAjaxAPI->_uploadInlineImage(Object(Draft))<br />
#6 [internal function]: DraftAjaxAPI->uploadInlineImage('555')<br />
#7 (root)/include/class.dispatcher.php(145): call_user_func_array(Array, Array)<br />
#8 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('555/attach', Array)<br />
#9 (root)/include/class.dispatcher.php(120): Dispatcher->resolve('555/attach', Array)<br />
#10 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('/draft/555/atta...', NULL)<br />
#11 (root)/scp/ajax.php(262): Dispatcher->resolve('/draft/555/atta...')<br />
#12 {main}

Comments

  • Please help us to help you by reading and following the posting guidelines located in this thread: Please read before requesting assistance.  The more information you give us the better we will be able to assist you. Thank you.

    Version of osTicket?
    Version of MySQL?

  • Thank you.. 
    Issue has been resolved.
    You can close the ticket.
  • What was your resolution?
  • I tracked down this issue. It is caused by a difference in behavior in MariaDB vs MySQL.

    It can be fixed by setting the "OLD_MODE" SQL system variable to "NO_DUP_KEY_WARNINGS_WITH_IGNORE" on the mysqli connection.

    Changes to /include/mysqli.php (around line 71):

    //set desired encoding just in case mysql charset is not UTF-8 - Thanks to FreshMedia
    @db_set_all(array(
    'NAMES' => 'utf8',
    'CHARACTER SET' => 'utf8',
    'COLLATION_CONNECTION' => 'utf8_general_ci',
    'SQL_MODE' => '',
    'OLD_MODE' => 'NO_DUP_KEY_WARNINGS_WITH_IGNORE'
    ), 'session');
Sign In or Register to comment.