craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.27k stars 635 forks source link

[5.x]: When merging entry types, the count includes drafts and revisions #15696

Open kennethormandy opened 1 month ago

kennethormandy commented 1 month ago

What happened?

Description

Best I can tell, the entry-types/merge command also includes drafts and revisions when counting entries. For example, I’m seeing:

craft entry-types/merge handle handle2
Which entry type should persist?

- handle (1 usage, 100 entries)
- handle2 (1 usage, 609 entries)

The handle section is 100 newly created entries, with no drafts or revisions, so that is all appearing as expected.

However, handle2 only has 34 entries. After clearing the revisions, the number is way lower, but I’m still not sure why it’s so high.

Steps to reproduce

  1. Run craft entry-types/merge handle handle2 and see the results
  2. Run craft utils/prune-revisions --max-revisions=0
  3. Run craft entry-types/merge handle handle2 again, and see the results are different

Craft CMS version

5.4.1

PHP version

8.2

Operating system and version

No response

Database type and version

PostgreSQL

Image driver and version

No response

Installed plugins and versions

No response

brandonkelly commented 1 month ago

Is the handle2 entry type used by any Matrix or CKEditor fields? The query to fetch those counts is just this:

https://github.com/craftcms/cms/blob/5e56c6d168524ed02f0620c9bc1c9750f5b94e3b/src/console/controllers/EntryTypesController.php#L65-L69

Drafts and revisions are not included in element queries by default, so those will not be included here.

brandonkelly commented 1 month ago

Might also be worth updating to Craft 5.4.2 and then running craft gc --delete-all-trashed.