[1.x] Entity Reference Delete Check

Created on 15 May 2023, about 1 year ago
Updated 19 May 2023, about 1 year ago

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 โ†’

๐Ÿ“Œ Task
Status

Fixed

Component

module

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany tgauges

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tgauges
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vishal.kadam Mumbai

    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.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vishal.kadam Mumbai
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vishal.kadam Mumbai

    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
    ---------------------------------------------------------------------------------------------------------------
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vishal.kadam Mumbai
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shashank5563 New Delhi

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

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany tgauges

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

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany tgauges

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vishal.kadam Mumbai

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shashank5563 New Delhi

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

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Rajan Kumar

    @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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vishal.kadam Mumbai

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

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany tgauges

    @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?

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany tgauges
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain alvar0hurtad0 Cรกceres

    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.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    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.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain alvar0hurtad0 Cรกceres

    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.

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain alvar0hurtad0 Cรกceres

    LGTM

  • Assigned to apaderno
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    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.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    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.

  • Status changed to Fixed about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024