Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing project.yaml fails when you change a field from matrix to something else #4015

Closed
RaederDev opened this issue Mar 20, 2019 · 4 comments
Assignees

Comments

@RaederDev
Copy link

Description

We had a field that was originally a Matrix field and changed it to type craft\fields\RadioButtons. Changing it locally worked but when you then sync the project.yaml against an environment that still has the matrix field in it it breaks.

This line: https://github.com/craftcms/cms/blob/develop/src/services/Matrix.php#L341
causes the problem because it assumes the field it fetches is a Matrix field (in our case a RadioButton was returned).

"Applying changes from project.yaml ... error: Getting unknown property: craft\fields\RadioButtons::contentTable"

Another problem is that there is no Stacktrace when something goes wrong because this piece of code just throw the exception information away: https://github.com/craftcms/cms/blob/develop/src/console/controllers/ProjectConfigController.php#L65

Why? Could you at least log the exception stacktrace please? I had to go in the code and manually get the trace.

Additional info

  • Craft version: Craft Pro 3.1.17.1
  • PHP version: 7.2.13
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions:
    Advanced Url Field | 1.0.0
    Migration Manager | 3.0.19
    Neo | 2.2.5
    Redactor | 2.3.2
@andris-sevcenko
Copy link
Contributor

Sorry for the oversight on the exception stack trace. Logging it as expected when encountering errors now.

As far as the original issue - we're discussing internally on the resolution for this, as it can go two ways:
a) changing a Matrix field to something else deletes all the block types, subfields, and content
or
b) handling block type changes should account for the possibility that the parent matrix field does not exist anymore.

Once we decide (probably today), I'll fix the rest of this issue.

@RaederDev
Copy link
Author

I think it would be a good idea to have it behave the same way it does when you change the fields in the CMS by hand.

@andris-sevcenko
Copy link
Contributor

andris-sevcenko commented Mar 21, 2019

I think it would be a good idea to have it behave the same way it does when you change the fields in the CMS by hand.

Right, the thing is that currently having a Matrix field to something else leaves the block types still existing in the database and the project config. So if you make changes to a block type, then change the matrix field to something else and push that project.yaml file, Project Config would react to block type changes and fail to find the matrix field.

We're trying to figure out if this is the "correct" behavior and we should make that part of the code more defensive to be OK with the parent field missing or if this in itself is a bug that the block types and everything else is not deleted when the field type changes.

@benface
Copy link
Contributor

benface commented Sep 13, 2019

@andris-sevcenko Think I just ran into this... I converted a Matrix field into a Table field and I'm seeing this error:

yii\base\UnknownPropertyException: Getting unknown property: craft\fields\Table::contentTable in vendor/yiisoft/yii2/base/Component.php:154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants