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

  1. Create a node of type "Article". Only fill the title.
  2. Translate the node, and embed an image in the CKEditor of the body field.
  3. Save the node.
  4. Delete the node and the translation
  5. 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

  1. Configure a new paragraph type with a formatted long text field that shows a CKEditor
  2. Add a new Entity Reference Revisions field to the "Article" content type and allow your new paragraph type.
  3. Create a node of type "Article", add a new paragraph and embed an image file in its CKEditor.
  4. Save the node
  5. Delete the node
  6. 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:
Before

After:
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

Issue fork drupal-3254880

Command icon 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

Omega_yang created an issue. See original summary.

Omega_yang’s picture

StatusFileSize
new4.46 KB

For version 9.2.10.

cilefen’s picture

Status: Active » Needs review
ranjith_kumar_k_u’s picture

StatusFileSize
new4.46 KB

Fixed CS errors.

ranjith_kumar_k_u’s picture

StatusFileSize
new4.46 KB
Omega_yang’s picture

StatusFileSize
new4.46 KB

Fixed CSpell errors.

Omega_yang’s picture

StatusFileSize
new4.5 KB

Fixed when delete empty paragraph field.

Status: Needs review » Needs work

The last submitted patch, 7: 3254880-7.patch, failed testing. View results

spokje’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: 3254880-7.patch, failed testing. View results

connbi’s picture

Version: 9.2.x-dev » 9.4.x-dev
Assigned: Omega_yang » connbi
Status: Needs work » Active
StatusFileSize
new4.53 KB

Create a new patch for drupal core 9.4.8

narendra.rajwar27’s picture

Status: Active » Needs review
StatusFileSize
new4.48 KB

Updated patch from #11 by fixing test failure. Interdiff of patches could not be generated.

Status: Needs review » Needs work

The last submitted patch, 12: 3254880-12.patch, failed testing. View results

connbi’s picture

StatusFileSize
new4.94 KB

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

solideogloria’s picture

Issue tags: +Needs reroll
solideogloria’s picture

Issue summary: View changes
solideogloria’s picture

Title: Update file usage number when delete node » Update file usage number when deleting a node

I 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.

solideogloria’s picture

Issue summary: View changes
solideogloria’s picture

Issue summary: View changes
solideogloria’s picture

Title: Update file usage number when deleting a node » Update file usage number when deleting a node with a translation
immaculatexavier’s picture

Status: Needs work » Needs review
StatusFileSize
new4.87 KB
new4.62 KB

Committed in accordance to #17 - Attached a patch for Reroll for version 11.x.
Kindly review .

needs-review-queue-bot’s picture

Status: Needs review » Needs work

The 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.)

immaculatexavier’s picture

immaculatexavier’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Will need test coverage

vidorado made their first commit to this issue’s fork.

vidorado’s picture

Issue summary: View changes
StatusFileSize
new62.49 KB
new62.9 KB
vidorado’s picture

Clean a bit the files section

vidorado’s picture

Title: Update file usage number when deleting a node with a translation » Update file usage number when translation or entity reference revisions (paragraphs) usages change
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs reroll, -Needs tests

Tests added! :)

smustgrave’s picture

Status: Needs review » Needs work

Left comment on MR.

vidorado’s picture

Status: Needs work » Needs review

I've managed to move the _editor_get_entity_reference_revisions() function to a helper service with unit test coverage.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The 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.

vidorado’s picture

Status: Needs work » Needs review

Rebased the MR.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new3.15 KB

The 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.

vidorado’s picture

Status: Needs work » Needs review

Updated the MR

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.74 KB

The 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.

vidorado’s picture

Status: Needs work » Needs review

Updated again

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.61 KB

The 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.