Problem/Motivation
After deleting a node's translation, the 'Status' and 'Used in' values of the Files list (/admin/content/files) won't be updated.
Steps to reproduce
Use case 1: File usages in translations
- Create a node of type "Article". Only fill the title.
- Translate the node, and embed an image in the CKEditor of the body field.
- Save the node.
- Delete the node and the translation
- Access '/admin/content/files'. The file status is 'Permanent', and the 'Used in' of the file is not 0.
Expectation: the image status is 'Temporary', and the 'Used in' of the file is 0.
Use case 2: File usages in paragraphs
- Configure a new paragraph type with a formatted long text field that shows a CKEditor
- Add a new Entity Reference Revisions field to the "Article" content type and allow your new paragraph type.
- Create a node of type "Article", add a new paragraph and embed an image file in its CKEditor.
- Save the node
- Delete the node
- Access '/admin/content/files', found status of the file is 'Permanent', 'Used in' of the file is not 0.
Expectation: the image status is 'Temporary', 'Used in' of the file is 0.
Proposed resolution
Refactor the editor module to account for usages in entity paragraphs and sub-paragraphs, and to correctly set the file status when usage is zero.
Before:

After:

Remaining tasks
- [✓] - Make a fix.
- [✓] - Tests.
User interface changes
The "Used in" column in /admin/content/files now reflects the correct usage count of files after entities using them are deleted.
API changes
None
Data model changes
None
Release notes snippet
NA
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | 3254880-nr-bot.txt | 2.61 KB | needs-review-queue-bot |
| #39 | 3254880-nr-bot.txt | 2.74 KB | needs-review-queue-bot |
| #37 | 3254880-nr-bot.txt | 3.15 KB | needs-review-queue-bot |
| #35 | 3254880-nr-bot.txt | 90 bytes | needs-review-queue-bot |
| #23 | 3254880_23.patch | 4.87 KB | immaculatexavier |
Issue fork drupal-3254880
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Omega_yang commentedFor version 9.2.10.
Comment #3
cilefen commentedComment #4
ranjith_kumar_k_u commentedFixed CS errors.
Comment #5
ranjith_kumar_k_u commentedComment #6
Omega_yang commentedFixed CSpell errors.
Comment #7
Omega_yang commentedFixed when delete empty paragraph field.
Comment #9
spokjeComment #11
connbi commentedCreate a new patch for drupal core 9.4.8
Comment #12
narendra.rajwar27Updated patch from #11 by fixing test failure. Interdiff of patches could not be generated.
Comment #14
connbi commentedComment #17
solideogloria commentedComment #18
solideogloria commentedComment #19
solideogloria commentedI added another reproduction of the issue that occurs with revisions and doesn't require that a site use translations.
Edit: I removed it. I noticed that this issue is for the editor module. I will create a separate issue, because my issue is probably for the file module.
Comment #20
solideogloria commentedComment #21
solideogloria commentedComment #22
solideogloria commentedComment #23
immaculatexavier commentedCommitted in accordance to #17 - Attached a patch for Reroll for version 11.x.
Kindly review .
Comment #24
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #26
immaculatexavier commentedComment #27
immaculatexavier commentedComment #28
smustgrave commentedWill need test coverage
Comment #30
vidorado commentedComment #31
vidorado commentedClean a bit the files section
Comment #32
vidorado commentedTests added! :)
Comment #33
smustgrave commentedLeft comment on MR.
Comment #34
vidorado commentedI've managed to move the
_editor_get_entity_reference_revisions()function to a helper service with unit test coverage.Comment #35
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #36
vidorado commentedRebased the MR.
Comment #37
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #38
vidorado commentedUpdated the MR
Comment #39
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #40
vidorado commentedUpdated again
Comment #41
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.