Problem/Motivation

drupal-check results

$ drupal-check -ad web/modules/contact_block

 1/1 [============================] 100%
 ------ ------------------------------------------------------------
  Line   src\Plugin\Block\ContactBlock.php
 ------ ------------------------------------------------------------
  117    \Drupal calls should be avoided in classes, use dependency injection instead
  126    \Drupal calls should be avoided in classes, use dependency injection instead
  191    \Drupal calls should be avoided in classes, use dependency injection instead
 ------ ------------------------------------------------------------

 [ERROR] Found 3 errors

Proposed resolution

update drupalci.yml

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mcdwayne created an issue. See original summary.

vuil’s picture

Status: Active » Needs review
StatusFileSize
new1.99 KB

I apply two small changes:

  • Update .info.yml tags.
  • Add drupalci.yml file.
vuil’s picture

Assigned: Unassigned » sutharsan

I assigned the issue for reviewing...

vuil’s picture

Issue summary: View changes

Update the summary with latest drupal-check issues.

vuil’s picture

Issue summary: View changes

Remove the last commit hash from issue's summary.

vuil’s picture

Status: Needs review » Needs work

I change the status to Needs work on new drupal-check -ad issues (updated summary).

vuil’s picture

Status: Needs work » Needs review
StatusFileSize
new6.19 KB

Update the #2 patch.

$ drupal-check -ad web/modules/contact_block

 1/1 [============================] 100%

 [OK] No errors
vuil’s picture

Hide the previous #2 patch.

vuil’s picture

Status: Needs review » Needs work
Issue tags: +Quickfix Need Reroll

Update the patch to latest 8.x-1.x-dev branch.

vuil’s picture

Status: Needs work » Needs review
StatusFileSize
new4.2 KB

Re-roll the patch #7.

Waiting for review from @Sutharsan.

sutharsan’s picture

Assigned: sutharsan » Unassigned
Status: Needs review » Needs work

Thanks for your contribution.

  1. +++ b/src/Plugin/Block/ContactBlock.php
    @@ -58,6 +60,21 @@ class ContactBlock extends BlockBase implements ContainerFactoryPluginInterface
    +   * The currunt router match.
    

    Typo 'current'
    'route' not 'router'

  2. +++ b/src/Plugin/Block/ContactBlock.php
    @@ -58,6 +60,21 @@ class ContactBlock extends BlockBase implements ContainerFactoryPluginInterface
    +   * @var \\Drupal\Core\Routing\CurrentRouteMatch
    

    One backslash too many.

  3. +++ b/src/Plugin/Block/ContactBlock.php
    @@ -75,14 +92,20 @@ class ContactBlock extends BlockBase implements ContainerFactoryPluginInterface
    +   * @param ContactPageAccess $access_check_contact_personal
    +   *   Check the access of personal contact.
    

    The variable name is confusing, and is not consistent with description. Naming things is hard, but I choose to base it on the class name of the underlying service:
    $this->checkContactPageAccess, $check_contact_page_access, Check access to contact page, etc.

-enzo-’s picture

StatusFileSize
new4.18 KB
new2.12 KB

Hi @Sutharsan

I follow your recommendation and apply those changes in patch #10.

Please review and let me know if works.

BTW drupal-check said all is OK

sutharsan’s picture

Issue tags: -Quickfix Need Reroll
+++ b/src/Plugin/Block/ContactBlock.php
@@ -75,14 +92,20 @@ class ContactBlock extends BlockBase implements ContainerFactoryPluginInterface
+   * @param ContactPageAccess $access_check_contact_personal
+   *   Check the access of personal contact.

Variable needs rename.
Use above property definition description.

-enzo-’s picture

StatusFileSize
new4.18 KB
new803 bytes

Hi @Sutharsan

Thank you for the review, attached you can find the changes, please let me know if I miss something

sutharsan’s picture

Some more observations:

  1. +++ b/src/Plugin/Block/ContactBlock.php
    @@ -58,6 +60,21 @@ class ContactBlock extends BlockBase implements ContainerFactoryPluginInterface
    +   * @var \Drupal\contact\Access\ContactPageAccess $accessCheckContactPersonal
    

    Do not append variable name to the type declaration.

  2. +++ b/src/Plugin/Block/ContactBlock.php
    @@ -75,14 +92,20 @@ class ContactBlock extends BlockBase implements ContainerFactoryPluginInterface
    +   * @param ContactPageAccess $check_contact_page_access
    

    See above. Also, use fully qualified class name.

sutharsan’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB
new4.09 KB

I tested the module with this patch, and found a but introduced by it. ContactBlock::defaultConfiguration is called when parent::__construct() is called and therefore before $this->configFactory is instantiated. Which causes an error in ContactBlock::defaultConfiguration. This patch delays parent::__construct() until all services are loaded.

I did not include the #15 comments.

vuil’s picture

I add my employer.

vinay15’s picture

Assigned: Unassigned » vinay15
Status: Needs review » Needs work

Verifying if #16 works and including feedback from #15.

vinay15’s picture

Assigned: vinay15 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.03 KB
new1.83 KB

Verified that #16 works fine and adding a patch that includes feedback from #15.

ranjith_kumar_k_u’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +GlobalContributionWeekend2020

latest patch applied successfully ,Performed drupal-check and foud no issues

abhijith s’s picture

StatusFileSize
new124.52 KB

I've applied the patch contact_block_d9_deprecated_code_report-3042649-19.patch for 8.x-1.x-dev. It was checked using drupal check and worked successfully

c-logemann’s picture

Issue tags: -GlobalContributionWeekend2020 +ContributionWeekend2020

"ContributionWeekend2020“ is the "official" tag suggested on global event page.

vuil’s picture

vuil’s picture

  • vuil committed c0b9807 on 8.x-1.x authored by Vinay15
    Issue #3042649 by vuil, -enzo-, Sutharsan, Vinay15, Abhijith S, mcdwayne...
vuil’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for the contribution!

The reviewed patch is committed! I closed the issue as Fixed!

c-logemann’s picture

@maintainer: Please remove my issue credit. I just fixed an issue tag which is a very simple minor contribution.

vuil’s picture

OK, Done!

Status: Fixed » Closed (fixed)

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