Ran the module code through code sniffer and found following errors:
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/nodeaccess.install
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
126 | WARNING | Variable $i is undefined.
--------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/nodeaccess.module
-------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------
316 | WARNING | Unused variable $results.
-------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/src/Form/ConfigForm.php
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------
48 | WARNING | NodeType::loadMultiple calls should be avoided in classes, use dependency injection instead
206 | WARNING | NodeType::loadMultiple calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/src/Form/GrantsForm.php
-------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------
221 | WARNING | Unused variable $preserve.
367 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
400 | WARNING | Unused variable $id.
-------------------------------------------------------------------------------------------------
Time: 277ms; Memory: 8MB
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/nodeaccess.install
----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/nodeaccess.module
------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
162 | ERROR | [x] Expected 1 blank line after function; 2 found
318 | ERROR | [x] Expected 1 space after WHILE keyword; 0 found
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/src/AccessChecks/NodeGrantAccessCheck.php
-------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
-------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/src/Form/ConfigForm.php
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------
FILE: /var/www/drupalvm/drupal/web/modules/contrib/nodeaccess/src/Form/GrantsForm.php
-------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
166 | ERROR | [x] Inline comments must start with a capital letter
174 | ERROR | [x] Inline comments must start with a capital letter
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------
Time: 498ms; Memory: 10MB
Comments
Comment #2
suresh prabhu parkala commentedPlease review the patch.
Comment #3
shashwat purav commentedThe patch in #2 failed to apply successfully to 8.x-1.x branch.
Comment #4
bruno.bicudoI'll work on it.
Comment #5
bruno.bicudoI worked on all the warnings and injected services.
Unused variables remained untouched as it's more suitable for someone with better understanding to touch them (see sniffer.txt).
Needs review :)
Comment #6
WagnerMelo commentedI'll review it.
Comment #7
WagnerMelo commentedI reviewed all changes that @bruno.bicudo made on #5, and evertything looks like correct for me!
I'll change this issues to RTBC.
Comment #8
jungleAll good, but I disagree with the variable naming. no need to use service in naming, eg, databaseService -> database. No similar naming like this in Drupal core.
Thanks!
Comment #9
aakansha tyagi commentedi am working on this issue.
Comment #10
aakansha tyagi commentedI have made the changes please review it.
Comment #11
michelecris commentedHi!
I will review it!
Comment #12
michelecris commentedHi!
I applied the #10 patch and searched for any variable with _service in name and all was changed. I also ran phpcs and any errors were found, just a warning in GrantsForm.php about a unused variable. So I think that is all good and l'll change the status for RTBC.
Thanks!
Comment #13
penyaskitoThe last two arguments should be the respective interfaces.
Comment #14
lucasbaralmI will work on this!
Comment #15
lucasbaralmAdding the fixes mentioned in comment #13 and adapting the order of related code to match the constructor.
Comment #16
penyaskitoThanks for working on this! I still don't see the changes I requested.
This should be NodeGrantDatabaseStorageInterface.
This should be MessengerInterface.
This should be MessengerInterface
This should be NGDSInterface.
These should be NGDSInterface and MessengerInterface.
Comment #17
penyaskitoComment #18
lucasbaralmSorry, I misunderstood the comment, I will work on the corrections.
Comment #19
lucasbaralmPlease ignore patch #15. Patch #19 corrects what was mentioned in comment #13.
Comment #20
penyaskitoThis looks good to me, thanks!
Comment #21
alisonThank you to everyone who collaborated and worked on this issue!
Comment #22
alisonComment #24
alisonComment #25
lussolucaThis patch introduced a bug in the ConfigForm class:
```
- $node_types = NodeType::loadMultiple();
+ $node_types = $this->entityTypeManager->getStorage('node')->loadMultiple();
```
should be `$node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple();`
And
```
- '#default_value' => isset($user_perms['author']['grant_view']) ? $user_perms['author']['grant_view'] : 0,
+ '#default_value' => isset($user_perms['author']['grant_view']) ?? 0,
```
should be `$user_perms['author']['grant_view'] ?? 0` (and all the others like this)
Should I open a new issue for that?
Comment #27
greatmatter commentedI have a patch here:
https://www.drupal.org/project/nodeaccess/issues/3309679
It might be wrong given #25. Let me know and I can update the patch. Note that the ?? operator is still being used incorrectly in *this* comment stream, but not my patch.
Comment #28
lussolucaGreat!, I think we can re-close this and move to #3309679: Nodeaccess configuration suddenly failed