wbrowar / craft-grid

A field that lets you content manage CSS Grid in Craft CMS.
Other
18 stars 2 forks source link

Incompatibility with Craft 3.2 when saving matrix fields #8

Closed wbrowar closed 4 years ago

wbrowar commented 5 years ago

If you're using Grid with a matrix block, please don't upgrade to Craft 3.2 until this issue is resolved

When saving a grid field that's target field is a matrix, the IDs that tie the grid field to the matrix blocks get out of sync as the matrix blocks are updated to create new drafts.

I'm not sure what the right solution is just yet, but I think for matrix blocks, using the indexes of the blocks might work.

wihodges commented 5 years ago

Oops well that's not good. Went into production without knowing this would break -- any idea when a fix will be released. It's acting very strangely and can't get a layout to save and somehow cleared out the old layout

wbrowar commented 5 years ago

Hi Will, I'm really sorry this is taking so long, but it's bigger bug than I expected. I'm hoping to get a fix out this weekend, but I'm still working on the right way to solve the problem without impacting current data. I'll keep you posted here.

wbrowar commented 5 years ago

Hi @wihodges, I put out a quick fix that I think should help when saving content with a grid field on it. This doesn't fully fix the issue in that there's still a problem with saving content as a draft. I might need to do a PR on the Craft CMS repo to fix that.

In the mean time, please take a backup of the DB and then try updating to Craft 3.2.5+ and updating to Grid 1.2.1 to see if this works a little better for you.

If you run into any issues, please let me know.

wihodges commented 5 years ago

Thanks for the update - I ended up reverting to a boring flex card design for the time being. Good luck with the bug!

ctruett commented 5 years ago

@wbrowar Hey man. How are the 3.2 compatibility fixes coming?

wbrowar commented 5 years ago

@ctruett The remaining bug seems to only be affected by matrix blocks changing their IDs when a matrix field is on content that is saved as a draft. At this point I think it’s safe to use grid in a couple of situations:

I think I have a good plan to fix this and I hope to get a new fix out there this weekend or sometime next week.

wbrowar commented 5 years ago

@wihodges @ctruett Okay, version 1.2.2 should fix the draft issue. If you upgrade, please keep a backup of the database nearby and try your grid fields out just in case, but I think this should resolve the 3.2 issues.

ctruett commented 5 years ago

@wihodges Awesome! I'll try it out now and let you know if I encounter anything weird.

ctruett commented 5 years ago

@wihodges Well, it appears that there is still an issue when saving entries. I've attached a copy of the error log below. Running the latest version of the plugin and craft. Any ideas?

yii\base\ErrorException: Undefined offset: 1 in /Users/cmtruett/Sites/dev.gcc/vendor/wbrowar/craft-grid/src/fields/Grid.php:308
Stack trace:
#0 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/web/ErrorHandler.php(81): yii\base\ErrorHandler->handleError(8, 'Undefined offse...', '/Users/cmtruett...', 308)
#1 /Users/cmtruett/Sites/dev.gcc/vendor/wbrowar/craft-grid/src/fields/Grid.php(308): craft\web\ErrorHandler->handleError(8, 'Undefined offse...', '/Users/cmtruett...', 308, Array)
#2 /Users/cmtruett/Sites/dev.gcc/vendor/wbrowar/craft-grid/src/fields/Grid.php(96): wbrowar\grid\fields\Grid->_updateTargetIds(Object(craft\elements\Entry))
#3 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/base/Element.php(2103): wbrowar\grid\fields\Grid->afterElementPropagate(Object(craft\elements\Entry), false)
#4 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/elements/Entry.php(1213): craft\base\Element->afterPropagate(false)
#5 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/services/Elements.php(661): craft\elements\Entry->afterPropagate(false)
#6 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/controllers/EntriesController.php(377): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#7 [internal function]: craft\controllers\EntriesController->actionSaveEntry(false)
#8 /Users/cmtruett/Sites/dev.gcc/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /Users/cmtruett/Sites/dev.gcc/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('save-entry', Array)
#11 /Users/cmtruett/Sites/dev.gcc/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-entry', Array)
#12 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/web/Application.php(299): yii\base\Module->runAction('entries/save-en...', Array)
#13 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/web/Application.php(566): craft\web\Application->runAction('entries/save-en...', Array)
#14 /Users/cmtruett/Sites/dev.gcc/vendor/craftcms/cms/src/web/Application.php(278): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#15 /Users/cmtruett/Sites/dev.gcc/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#16 /Users/cmtruett/Sites/dev.gcc/web/index.php(21): yii\base\Application->run()
#17 {main}
wbrowar commented 5 years ago

Hmm let me take a look into this. Do you know if there's either the matrix field or the grid field that has no value?

ctruett commented 5 years ago

I think it is the grid field.

wbrowar commented 5 years ago

Hi @ctruett

I'm unable to re-create this issue, but I did put in a quick check that might resolve this. Can you please unzip this and use it to replace the file located at:

vendor/wbrowar/grid/src/fields/Grid.php

Grid.php.zip