Fixed XF\Db\DuplicateKeyException: MySQL query error

Siraç

Member
Affected version
2.0.2
Code:
     XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '8861-194339' for key 'PRIMARY' src/XF/Db/AbstractStatement.php:212
    
     INSERT  INTO `xf_thread_watch` (`thread_id`, `user_id`, `email_subscribe`) VALUES (?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(79): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(160): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1389): XF\Db\AbstractAdapter->insert('xf_thread_watch', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1121): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Repository/ThreadWatch.php(68): XF\Mvc\Entity\Entity->save()
#7 src/XF/Pub/Controller/Thread.php(1087): XF\Repository\ThreadWatch->setWatchState(Object(XF\Entity\Thread), Object(XF\Entity\User), 'watch_no_email')
#8 src/XF/Mvc/Dispatcher.php(249): XF\Pub\Controller\Thread->actionWatch(Object(XF\Mvc\ParameterBag))
#9 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'Watch', 'json', Object(XF\Mvc\ParameterBag), 'forums', Object(XF\Pub\Controller\Thread), NULL)
#10 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#11 src/XF/App.php(1889): XF\Mvc\Dispatcher->run()
#12 src/XF.php(328): XF\App->run()
#13 index.php(13): XF::runApp('XF\\Pub\\App')
#14 {main}

array(4) {
  ["url"] => string(101) "/konu/gelenek-ve-goreneklerimiz-nelerdir-turkiye-de-gelenek-ve-gorenekler-hakkinda-bilgi.194339/watch"
  ["referrer"] => string(124) "https://www.example.com/konu/gelenek-ve-goreneklerimiz-nelerdir-turkiye-de-gelenek-ve-gorenekler-hakkinda-bilgi.194339/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(5) {
    ["email_subscribe"] => string(1) "0"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(96) "/konu/gelenek-ve-goreneklerimiz-nelerdir-turkiye-de-gelenek-ve-gorenekler-hakkinda-bilgi.194339/"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
These are generally safe to ignore as they usually just indicate a race condition of some sort, but we've added something to catch this in the next release. Thanks.
 
Back
Top Bottom