I created a small module which warns content moderators about existing entity references when deleting a content entity. The module implements an alter hook for any form whose form object is an instance of \Drupal\Core\Entity\ContentEntityDeleteForm. In this hook, all entity reference fields on fieldable entities are checked for existing references to the entity and presented to the user.

A similar use case is implemented by https://www.drupal.org/project/entity_reference_delete which deletes related entities.

Project link

https://www.drupal.org/project/entity_reference_delete_check

Comments

tgauges created an issue. See original summary.

vishal.kadam’s picture

Thank you for applying! Reviewers will review the project files, describing what needs to be changed.

Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

To reviewers: Please read How to review security advisory coverage applications, What to cover in an application review, and Drupal.org security advisory coverage application workflow.

While this application is open, only the user who opened the application can make commits to the project used for the application.

Reviewers only describe what needs to be changed; they don't provide patches to fix what reported in a review.

vishal.kadam’s picture

Issue summary: View changes
vishal.kadam’s picture

Fix phpcs issues.

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml entity_reference_delete_check/

FILE: entity_reference_delete_check/entity_reference_delete_check.module
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
  7 | ERROR   | [ ] Missing short description in doc comment
 52 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use '' quotes instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: entity_reference_delete_check/modules/entity_reference_delete_check_paragraph_url/src/EventSubscriber/ParagraphUrlProvider.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------------------------------------------
  7 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
 11 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
 15 | ERROR   | [x] Missing function doc comment
 21 | ERROR   | [x] Missing function doc comment
 34 | ERROR   | [x] Expected newline after closing brace
 35 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: entity_reference_delete_check/README.md
-----------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------
  3 | WARNING | Line exceeds 80 characters; contains 128 characters
 17 | WARNING | Line exceeds 80 characters; contains 90 characters
-----------------------------------------------------------------------------


FILE: entity_reference_delete_check/src/Dto/UsageResult.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 22 | ERROR | Missing short description in doc comment
 23 | ERROR | Missing parameter comment
--------------------------------------------------------------------------------


FILE: entity_reference_delete_check/src/Event/DeleteCheckEntityUrlEvent.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------------------------------------------
 12 | WARNING | [ ] Line exceeds 80 characters; contains 119 characters
 16 | ERROR   | [ ] Missing member variable doc comment
 18 | ERROR   | [ ] Missing member variable doc comment
 20 | ERROR   | [x] Missing function doc comment
 24 | ERROR   | [x] Missing function doc comment
 28 | ERROR   | [x] Missing function doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: entity_reference_delete_check/src/EventSubscriber/DeleteCheckEntityUrlEventSubscriber.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
--------------------------------------------------------------------------------
  6 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
 10 | WARNING | [ ] Line exceeds 80 characters; contains 122 characters
 14 | ERROR   | [x] Missing function doc comment
 20 | ERROR   | [x] Missing function doc comment
 24 | ERROR   | [x] Expected newline after closing brace
 25 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: entity_reference_delete_check/src/Service/EntityReferenceUsageChecker.php
--------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 6 LINES
--------------------------------------------------------------------------------
 19 | ERROR | [ ] Missing member variable doc comment
 21 | ERROR | [ ] Missing member variable doc comment
 23 | ERROR | [ ] Missing member variable doc comment
 25 | ERROR | [x] Missing function doc comment
 49 | ERROR | [ ] Description for the @return value is missing
 81 | ERROR | [x] Expected newline after closing brace
 81 | ERROR | [x] Expected 1 space before "|"; 0 found
 81 | ERROR | [x] Expected 1 space after "|"; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
vishal.kadam’s picture

Status: Needs review » Needs work
shashank5563’s picture

Please remove the docker-compose.yml and .docker folder from the branch. No need of these two things in Drupal module contribution.

tgauges’s picture

@shashank5563 I created a .gitattributes file to ignore all development files when packaging a release. I'd like to keep the files inside the git repository for easier development.

tgauges’s picture

Status: Needs work » Needs review

@vishal.kadam I fixed the issues reported by phpcs.

vishal.kadam’s picture

@tgauges I have reviewed the changes, and they look fine to me.

Let’s wait for other reviewers to take a look and if everything goes fine, you will get the role.

shashank5563’s picture

@tgauges, Rest look fine for me. Let's wait other reviewers.

rajan kumar’s picture

Status: Needs review » Needs work

@tgauges

Remove these files from your branch 1.x, these files should not be in any Drupal Contributed module.
docker-compose.yml
.docker folder
.gitattributes
.gitignore

vishal.kadam’s picture

.gitignore files are allowed. There is no need to delete them.

tgauges’s picture

@Rajan Kumar Is it not enough to follow the recommendation in https://www.drupal.org/node/1068944#exclude and exclude these files when packaging a release?

tgauges’s picture

Status: Needs work » Needs review
alvar0hurtad0’s picture

Status: Needs review » Needs work

Hello @tgauges,

you should include only the module in the repo.

the repository should be inisialized into the

entity_reference_delete_check_paragraph_url

folder in your case.

avpaderno’s picture

There is a main module (Entity Reference Delete Check) and a sub-module (Entity Reference Delete Check Paragraph Url). I guess it has been so because the sub-module could be replaced by another module implemented as a different project; having a sub-module allows users to not install it, if they have a replacement module.

alvar0hurtad0’s picture

Status: Needs work » Needs review

Sorry for the confusion @apaderno @tgauges, you're right.

I learned something today, thanks for that.

I'll do a deeper review of the code.

alvar0hurtad0’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

avpaderno’s picture

Assigned: Unassigned » avpaderno

core_version_requirement: ^9 || ^10

Since the module is using a PHP feature that is available starting with PHP 7.4, and Drupal 9.4 dropped the support for PHP versions lower that PHP 7.4, the required Drupal 9 version should be increased.

avpaderno’s picture

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the Slack #contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the reviewers.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.