-
Notifications
You must be signed in to change notification settings - Fork 3
Duplicate Entry error related to categories #7
Description
I have one channel that does not clone when requested (or generate an error message for the first attempt). This is the same channel as my previous issue. When I then try a second time to clone the same entry, I get the following error message:
Exception Caught
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '78-17' for key 'PRIMARY':
INSERT INTO `exp_category_posts` (`entry_id`, `cat_id`) VALUES (78, 17)
ee/legacy/database/drivers/mysqli/mysqli_connection.php:122
Entry 78 already exists (in a different channel that doesn't use that category group). When I look at exp_category_posts, it has created new rows for entry 78. When I remove the new rows for 78 and try to clone the entry again, it adds the rows back into exp_category_posts. When I try to clone the entry yet another time, I get the Duplicate entry error again.
Entry 78 is the most recent entry created on the site. When I create a new entry in another channel, the Duplicate entry error (and the database) indicates that SimpleCloner is trying to create the categories for the very newest entry.
If it helps, this channel has two category groups and the following field types:
- relationship
- bloqs
- grid (with ansel, text, url columns)
- publish_notes
- ansel
- url
Here is the stack trace for the error message:
#0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(137): CI_DB_mysqli_connection->query('INSERT INTO `ex...')
#1 ee/legacy/database/DB_driver.php(297): CI_DB_mysqli_driver->_execute('INSERT INTO `ex...')
#2 ee/legacy/database/DB_driver.php(203): CI_DB_driver->simple_query('INSERT INTO `ex...')
#3 ee/legacy/database/DB_active_rec.php(1462): CI_DB_driver->query('INSERT INTO `ex...')
#4 user/addons/simple_cloner/ext.simple_cloner.php(278): CI_DB_active_record->insert('category_posts', Array)
#5 ee/legacy/libraries/Extensions.php(243): Simple_cloner_ext->simple_cloner_content_save(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#6 ee/legacy/libraries/Extensions.php(138): EE_Extensions->call_class('Simple_cloner_e...', 'after_channel_e...', Array, Array)
#7 [internal function]: EE_Extensions->call('after_channel_e...', Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#8 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(642): call_user_func_array(Array, Array)
#9 [internal function]: EllisLab\ExpressionEngine\Service\Model\Model->EllisLab\ExpressionEngine\Service\Model\{closure}('after_channel_e...', Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry), Array)
#10 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(615): call_user_func_array(Object(Closure), Array)
#11 [internal function]: EllisLab\ExpressionEngine\Service\Model\Model->EllisLab\ExpressionEngine\Service\Model\{closure}()
#12 ee/EllisLab/ExpressionEngine/Service/Event/Emitter.php(153): call_user_func_array(Object(Closure), Array)
#13 [internal function]: EllisLab\ExpressionEngine\Service\Event\Emitter->emit('afterSave')
#14 ee/EllisLab/ExpressionEngine/Library/Data/Entity.php(629): call_user_func_array(Array, Array)
#15 [internal function]: EllisLab\ExpressionEngine\Library\Data\Entity->emit('afterSave')
#16 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(834): call_user_func_array('parent::emit', Array)
#17 ee/EllisLab/ExpressionEngine/Service/Model/Query/Update.php(60): EllisLab\ExpressionEngine\Service\Model\Model->emit('afterSave')
#18 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(294): EllisLab\ExpressionEngine\Service\Model\Query\Update->run()
#19 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(260): EllisLab\ExpressionEngine\Service\Model\DataStore->runQuery('Update', Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#20 ee/EllisLab/ExpressionEngine/Service/Model/Query/Builder.php(83): EllisLab\ExpressionEngine\Service\Model\DataStore->updateQuery(Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))
#21 ee/EllisLab/ExpressionEngine/Service/Model/Model.php(366): EllisLab\ExpressionEngine\Service\Model\Query\Builder->update()
#22 ee/EllisLab/ExpressionEngine/Model/Content/ContentModel.php(198): EllisLab\ExpressionEngine\Service\Model\Model->save()
#23 ee/EllisLab/ExpressionEngine/Controller/Publish/AbstractPublish.php(295): EllisLab\ExpressionEngine\Model\Content\ContentModel->save()
#24 ee/EllisLab/ExpressionEngine/Controller/Publish/Edit.php(482): EllisLab\ExpressionEngine\Controller\Publish\AbstractPublish->saveEntryAndRedirect(Object(EllisLab\ExpressionEngine\Model\Channel\ChannelEntry))
#25 [internal function]: EllisLab\ExpressionEngine\Controller\Publish\Edit->entry('33')
#26 ee/EllisLab/ExpressionEngine/Core/Core.php(189): call_user_func_array(Array, Array)
#27 ee/EllisLab/ExpressionEngine/Core/Core.php(94): EllisLab\ExpressionEngine\Core\Core->runController(Array)
#28 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))
#29 html/mmdcms/index.php(143): require_once('...')
#29 html/mmdcms/index.php(143): require_once('...')