timmyomahony / craft-matrix-field-preview

Configure a screenshot preview for all your matrix field blocks, giving your clients a better publishing experience.
https://plugins.craftcms.com/matrix-field-preview
Other
16 stars 4 forks source link

Getting unknown property: weareferal\matrixfieldpreview\records\NeoBlockTypeConfigRecord::sortOrder #86

Closed deanfields closed 2 years ago

deanfields commented 2 years ago

I'm playing around with a clean install, I have a Neo field that had one block, and I was able to add a preview. I have since added a second block and that has caused this error to occur on the Neo configure previews page. I removed one of the blocks and the page worked again.

deanfields commented 2 years ago

Having looked at the code and what is going on, the column 'sortOrder' is missing from the matrixfieldpreview_neo_blocktypes_config table for some reason, I didn't manually remove it, so not sure what happened. Interestingly the page errored even when there was only one block on the neo field - even though yesterday it seemed to work. Not sure if something is changing the table structure.

Adding it onto the table fixed the issue for me

timmyomahony commented 2 years ago

Thanks @deanfields. You're correct, the plugin has it's own tables in the DB to track previews. It should have added that field to the database via a migration though so not sure what's happened.

deanfields commented 2 years ago

It was a fresh install of Craft 4 and I can't recall what order I installed the plugins in, but I feel like I may have installed MFP first. And yes, it was a fresh install as opposed to an update.

timmyomahony commented 2 years ago

This should now be fixed in release 4.0.3:

https://github.com/weareferal/craft-matrix-field-preview/releases/tag/4.0.3

The issue was that there was a migration I had failed to include in the code that runs when Neo is installed, meaning that sortOrder row wasn't installed properly.

This should avoid the issue happening in the future but to fix an existing installation you might need to reinstall Neo so that the migration runs correctly. This would obviously mean losing configurations for Neo.

If that's too much hassle the easiest thing to do is to manually add a sortOrder column to the table matrixfieldpreview_neo_blocktypes_config in your database and make it type smallint

CleanShot 2022-08-24 at 23 47 16@2x