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

[4.x]: Craft not deleting nested fields properly #13456

Closed
mikesnoeren opened this issue Jul 20, 2023 · 3 comments
Closed

[4.x]: Craft not deleting nested fields properly #13456

mikesnoeren opened this issue Jul 20, 2023 · 3 comments
Assignees

Comments

@mikesnoeren
Copy link

What happened?

Description

When deleting a Matrix (or SuperTable) field, the inner fields are not deleted properly and leave traces of themselve in the project file and database.

I have tested this using a clean installation on the latest version of Craft.

Steps to reproduce

  1. Create a matrix field (or supertable field) with a plain text field.
  2. Collect the text fields UID from the project file. (project.yaml -> meta -> __names__)
  3. Delete the field matrix field in Craft.
  4. Search the project file and the database for the UID.
  5. Find traces of the text field in the project files and in the database.

Expected behavior

All fields have to be deleted properly

Extra test results when deleting fields

Type Removed in project.yaml Removed in DB
Plain Text Yes Yes
Matrix Yes Yes
Matrix Block Yes Yes
Matrix Block Field (Plain Text) No No
SuperTable Yes Yes
SuperTable Field (Plain Text) No No

Craft CMS version

4.4.14

PHP version

8.0

Operating system and version

DDEV project type: craftcms

Database type and version

Mysql 5.7

Image driver and version

No response

Installed plugins and versions

  • Super Table: 3.0.9
@mikesnoeren
Copy link
Author

@i-just, thanks for the fix, is there an easy way for us to clean up projects that were affected by this bug?

@brandonkelly
Copy link
Member

@mikesnoeren Looks like @i-just is working on a new command to simplify this (#13503), but in the meantime you can do the following:

  1. Delete the entire meta.__names__ array from config/project/project.yaml
  2. Run php craft project-config/apply (to pull in the manual change)
  3. Run php craft project-config/rebuild (to rebuild everything, including the meta.__names__ array)

brandonkelly added a commit that referenced this issue Aug 4, 2023
@brandonkelly
Copy link
Member

Craft 4.4.17 is out with a fix that ensures nested deleted component names are removed from the meta.__names__ map immediately, as well as an improvement to the project-config/rebuild command to ensure the whole meta.__names__ map is rebuilt.

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

No branches or pull requests

3 participants