Skip to content

[4.x]: relations table not being cleaned up when editing entry types #13956

@ryssbowh

Description

@ryssbowh

What happened?

Description

I'm not sure this is intended but the relations table doesn't seem to be cleaned up when removing a field from an entry type, and querying relatedTo elements does return results where it shouldn't.

If you have an entry type that contains let's say an asset field, and an entry with some value in it ($element in the following query). Then remove the field from the entry type. The query :

Entry::find()->relatedTo(['targetElement' => $element])->all()

still returns results.

I've resaved those entries, ran gc, but they're still in the relations table.

Steps to reproduce

  1. Create an Asset field
  2. Add the field to an Entry type
  3. Create an entry of that type
  4. Remove the asset field from the entry type
  5. Run the query above

Expected behavior

That query doesn't return results

Craft CMS version

4.5.11

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions