You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After submit via "Approve and publish" an exception is thrown with "Integrity constraint violation" - see stack trace below - but the entry is saved and updated.
The workflow submission is listed as a deleted item.
Steps to reproduce
login as editor (can only create drafts)
create draft from existing entry (e.g. from single section type)
submit draft for approval with "Save draft and submit for review" button
login as chief editor
try to approve and publish item with "Approve and publish" button
Yeah this is a tricky one. It's because the entry element (the draft) that Workflow is working with actually gets deleted when it's approved, hence when trying to save the Workflow Submission that is linked to that now-deleted entry element causes this error.
Describe the bug
After submit via "Approve and publish" an exception is thrown with "Integrity constraint violation" - see stack trace below - but the entry is saved and updated.
The workflow submission is listed as a deleted item.
Steps to reproduce
Craft CMS version
4.2.1.1
Plugin version
dev-craft-4 as 2.0.0-beta.5
Multi-site?
Yes
Additional context
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
db
.workflow_submissions
, CONSTRAINTfk_diqywvmwbslvmuhwmydkadgiokqfxjoigxty
FOREIGN KEY (ownerId
) REFERENCESelements
(id
) ON DELETE SET NULL) in /var/www/html/vendor/yiisoft/yii2/db/Command.php:1302Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('UPDATE `workflo...')
#2 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(336): yii\db\Command->execute()
#3 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(808): yii\db\ActiveRecord::updateAll(Array, Array)
#4 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(680): yii\db\BaseActiveRecord->updateInternal(NULL)
#5 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(679): yii\db\ActiveRecord->update(false, NULL)
#6 /var/www/html/vendor/verbb/workflow/src/elements/Submission.php(458): yii\db\BaseActiveRecord->save(false)
#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2730): verbb\workflow\elements\Submission->afterSave(false)
#8 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(795): craft\services\Elements->_saveElementInternal(Object(verbb\workflow\elements\Submission), true, false, true)
#9 /var/www/html/vendor/verbb/workflow/src/services/Submissions.php(297): craft\services\Elements->saveElement(Object(verbb\workflow\elements\Submission))
#10 /var/www/html/vendor/verbb/workflow/src/services/Service.php(193): verbb\workflow\services\Submissions->approveSubmission(Object(craft\elements\Entry))
#11 [internal function]: verbb\workflow\services\Service->onAfterApplyDraft(Object(craft\events\DraftEvent))
#12 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(craft\events\DraftEvent))
#13 /var/www/html/vendor/yiisoft/yii2/base/Component.php(642): yii\base\Event::trigger('craft\services\...', 'afterApplyDraft', Object(craft\events\DraftEvent))
#14 /var/www/html/vendor/craftcms/cms/src/services/Drafts.php(340): yii\base\Component->trigger('afterApplyDraft', Object(craft\events\DraftEvent))
#15 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(1275): craft\services\Drafts->applyDraft(Object(craft\elements\Entry))
#16 [internal function]: craft\controllers\ElementsController->actionApplyDraft()
#17 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#18 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#19 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('apply-draft', Array)
#20 /var/www/html/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('elements/apply-...', Array)
#21 /var/www/html/vendor/verbb/workflow/src/controllers/SubmissionsController.php(106): craft\web\Application->runAction('elements/apply-...')
#22 [internal function]: verbb\workflow\controllers\SubmissionsController->actionPublishEntry()
#23 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#24 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#25 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('publish-entry', Array)
#26 /var/www/html/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('workflow/submis...', Array)
#27 /var/www/html/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('workflow/submis...', Array)
#28 /var/www/html/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#29 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#30 /var/www/html/web/index.php(12): yii\base\Application->run()
#31 {main}
Next yii\db\IntegrityException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
db
.workflow_submissions
, CONSTRAINTfk_diqywvmwbslvmuhwmydkadgiokqfxjoigxty
FOREIGN KEY (ownerId
) REFERENCESelements
(id
) ON DELETE SET NULL)The SQL being executed was: UPDATE
workflow_submissions
SETownerId
=3046,publisherId
=667,status
='approved',publisherNotes
='Yes!',dateApproved
='2022-08-23 13:54:03',dateUpdated
='2022-08-23 13:54:03' WHEREid
=3048 in /var/www/html/vendor/yiisoft/yii2/db/Schema.php:676Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'UPDATE
workflo...') #1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('UPDATE
workflo...')#2 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(336): yii\db\Command->execute()
#3 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(808): yii\db\ActiveRecord::updateAll(Array, Array)
#4 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(680): yii\db\BaseActiveRecord->updateInternal(NULL)
#5 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(679): yii\db\ActiveRecord->update(false, NULL)
#6 /var/www/html/vendor/verbb/workflow/src/elements/Submission.php(458): yii\db\BaseActiveRecord->save(false)
#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2730): verbb\workflow\elements\Submission->afterSave(false)
#8 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(795): craft\services\Elements->_saveElementInternal(Object(verbb\workflow\elements\Submission), true, false, true)
#9 /var/www/html/vendor/verbb/workflow/src/services/Submissions.php(297): craft\services\Elements->saveElement(Object(verbb\workflow\elements\Submission))
#10 /var/www/html/vendor/verbb/workflow/src/services/Service.php(193): verbb\workflow\services\Submissions->approveSubmission(Object(craft\elements\Entry))
#11 [internal function]: verbb\workflow\services\Service->onAfterApplyDraft(Object(craft\events\DraftEvent))
#12 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(craft\events\DraftEvent))
#13 /var/www/html/vendor/yiisoft/yii2/base/Component.php(642): yii\base\Event::trigger('craft\services\...', 'afterApplyDraft', Object(craft\events\DraftEvent))
#14 /var/www/html/vendor/craftcms/cms/src/services/Drafts.php(340): yii\base\Component->trigger('afterApplyDraft', Object(craft\events\DraftEvent))
#15 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(1275): craft\services\Drafts->applyDraft(Object(craft\elements\Entry))
#16 [internal function]: craft\controllers\ElementsController->actionApplyDraft()
#17 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#18 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#19 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('apply-draft', Array)
#20 /var/www/html/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('elements/apply-...', Array)
#21 /var/www/html/vendor/verbb/workflow/src/controllers/SubmissionsController.php(106): craft\web\Application->runAction('elements/apply-...')
#22 [internal function]: verbb\workflow\controllers\SubmissionsController->actionPublishEntry()
#23 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#24 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#25 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('publish-entry', Array)
#26 /var/www/html/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('workflow/submis...', Array)
#27 /var/www/html/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('workflow/submis...', Array)
#28 /var/www/html/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#29 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#30 /var/www/html/web/index.php(12): yii\base\Application->run()
#31 {main}
Additional Information:
Array
(
[0] => 23000
[1] => 1452
[2] => Cannot add or update a child row: a foreign key constraint fails (
db
.workflow_submissions
, CONSTRAINTfk_diqywvmwbslvmuhwmydkadgiokqfxjoigxty
FOREIGN KEY (ownerId
) REFERENCESelements
(id
) ON DELETE SET NULL))
The text was updated successfully, but these errors were encountered: