verbb / workflow

A Craft CMS plugin to create a workflow for publishing entries.
Other
140 stars 27 forks source link

One of Workflow’s migrations failed when updating to Craft 4 #186

Closed sandrodunkel closed 1 year ago

sandrodunkel commented 1 year ago

Question

I'm coming from Craft 3.8. When updating to Craft 4 and Workflow 2.0.4 i get the following error when finishing up the database. The project comes from an early Craft 3 version, maybe even Craft 2. I also tried uninstalling and then re-installing the plugin; with no success. Maybe someone has an input?

# One of Workflow’s migrations failed.
Integrity constraint violation: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (shacc3.workflow_reviews, CONSTRAINT fk_bcatgfbakqeohiizljygxmiklmijcvmthapc FOREIGN KEY (draftId) REFERENCES drafts (id) ON DELETE SET NULL)
The SQL being executed was: INSERT INTO workflow_reviews (submissionId, elementId, draftId, status, data, dateUpdated, role, userId, notes, dateCreated, uid) VALUES (2576, 2573, 7, 'pending', NULL, '2018-12-05 21:34:26', 'editor', 692, NULL, '2023-03-29 13:27:00', 'de60fc70-126a-448f-9fc7-1108a2a4a502')

Additional context

No response

engram-design commented 1 year ago

So according to the error, the review contains a reference to a draft entry with the ID of 7. That no longer exists on your install for whatever reason. However, this is reasonably normal, because drafts do get deleted when merged. It's likely that Workflow for Craft 3 just didn't provide a proper cleanup when the draft was deleted. Or, there was lacking foreign key checks.

However, I've added some checks to prevent the migration from failing. To get this early, run composer require verbb/workflow:"dev-craft-4 as 2.0.4"

sandrodunkel commented 1 year ago

Worked like a charm – thank you very much! I assume that this will also be part of an upcoming update (instead of running the dev-version for ages)?

sandrodunkel commented 1 year ago

Actually, if I open some of the older workflows that already exist, on some of them I get the following error. It's not all of them and I can't seem to figure out a pattern.

LitEmoji\LitEmoji::shortcodeToUnicode(): Argument #1 ($content) must be of type string, null given, called in /vendor/verbb/workflow/src/helpers/StringHelper.php on line 25
engram-design commented 1 year ago

Can you provide the full stack trace of the error? Just need to backtrack to where it's coming from.

engram-design commented 1 year ago

Just pushed a fix for this in the meantime. To get this early, run composer require verbb/workflow:"dev-craft-4 as 2.0.4" - and yes this will be added to the next release, so you can switch back from the dev-craft-4 branch when released.

sandrodunkel commented 1 year ago
TypeError: LitEmoji\LitEmoji::shortcodeToUnicode(): Argument #1 ($content) must be of type string, null given, called in /vendor/verbb/workflow/src/helpers/StringHelper.php on line 25 and defined in /vendor/elvanto/litemoji/src/LitEmoji.php:62
Stack trace:
#0 /vendor/verbb/workflow/src/helpers/StringHelper.php(25): LitEmoji\LitEmoji::shortcodeToUnicode(NULL)
#1 /vendor/verbb/workflow/src/models/Review.php(98): verbb\workflow\helpers\StringHelper::unSanitizeNotes(NULL)
#2 /vendor/yiisoft/yii2/base/Component.php(139): verbb\workflow\models\Review->getNotes()
#3 /vendor/craftcms/cms/src/helpers/Template.php(135): yii\base\Component->__get('notes')
#4 /storage/runtime/compiled_templates/2c/2c6ded66470dbabd7912b47e146a3a31.php(340): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(verbb\workflow\models\Review), 'notes', Array)
#5 /vendor/twig/twig/src/Template.php(171): __TwigTemplate_e157e1edad6583a0c99dc35fa40d1bfb->block_main(Array, Array)
#6 /storage/runtime/compiled_templates/55/556236f1081c0bc3773dd133218ba935.php(376): Twig\Template->displayBlock('main', Array, Array)
#7 /vendor/twig/twig/src/Template.php(171): __TwigTemplate_28186521361488afc295cf1c51d67982->block_body(Array, Array)
#8 /storage/runtime/compiled_templates/97/973b2173bc30e762897596e7e71a2941.php(94): Twig\Template->displayBlock('body', Array, Array)
#9 /vendor/twig/twig/src/Template.php(394): __TwigTemplate_65bc4559dd5525e31f19d5db02ee7c00->doDisplay(Array, Array)
#10 /vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#11 /storage/runtime/compiled_templates/82/82a292e03adf38af20bc6c2bc4ea7cc5.php(56): Twig\Template->display(Array, Array)
#12 /vendor/twig/twig/src/Template.php(394): __TwigTemplate_c89542fdbb0c8c6a910c5f4a9ec44531->doDisplay(Array, Array)
#13 /vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#14 /storage/runtime/compiled_templates/55/556236f1081c0bc3773dd133218ba935.php(179): Twig\Template->display(Array, Array)
#15 /vendor/twig/twig/src/Template.php(394): __TwigTemplate_28186521361488afc295cf1c51d67982->doDisplay(Array, Array)
#16 /vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#17 /storage/runtime/compiled_templates/2c/2c6ded66470dbabd7912b47e146a3a31.php(104): Twig\Template->display(Array, Array)
#18 /vendor/twig/twig/src/Template.php(394): __TwigTemplate_e157e1edad6583a0c99dc35fa40d1bfb->doDisplay(Array, Array)
#19 /vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#20 /vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
#21 /vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render(Array, Array)
#22 /vendor/twig/twig/src/Environment.php(277): Twig\TemplateWrapper->render(Array)
#23 /vendor/craftcms/cms/src/web/View.php(456): Twig\Environment->render('workflow/submis...', Array)
#24 /vendor/craftcms/cms/src/web/View.php(509): craft\web\View->renderTemplate('workflow/submis...', Array)
#25 /vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(56): craft\web\View->renderPageTemplate('workflow/submis...', Array, 'cp')
#26 /vendor/yiisoft/yii2/web/Response.php(1098): craft\web\TemplateResponseFormatter->format(Object(craft\web\Response))
#27 /vendor/craftcms/cms/src/web/Response.php(286): yii\web\Response->prepare()
#28 /vendor/yiisoft/yii2/web/Response.php(339): craft\web\Response->prepare()
#29 /vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#30 /web/index.php(12): yii\base\Application->run()
#31 {main}
sandrodunkel commented 1 year ago

Any updates on this?

engram-design commented 1 year ago

This fix was already incorporated into dev-craft-4 if you were able to try it? Updated in 2.0.5