When module installed. In the page /admin/config/content/nodeviewcount
has the errors:
TypeError: Drupal\nodeviewcount\Form\NodeViewCountSettingsForm::getRoleNamesOptions(): Argument #1 ($excluded_user_roles) must be of type array, null given, called in /var/www/html/web/modules/contrib/nodeviewcount/src/Form/NodeViewCountSettingsForm.php on line 123 in Drupal\nodeviewcount\Form\NodeViewCountSettingsForm->getRoleNamesOptions() (line 206 of modules/contrib/nodeviewcount/src/Form/NodeViewCountSettingsForm.php). .

Comments

nblack69 created an issue. See original summary.

nblack69’s picture

Issue summary: View changes
nblack69’s picture

Priority: Major » Critical
siddharthjain’s picture

I am not able to reproduce this issue.

nblack69’s picture

I have drupal 9.5.3 and php 8.1.16
I get this :

 The website encountered an unexpected error. Please try again later.
TypeError: Drupal\nodeviewcount\Form\NodeViewCountSettingsForm::getRoleNamesOptions(): Argument #1 ($excluded_user_roles) must be of type array, null given, called in /var/www/html/web/modules/contrib/nodeviewcount/src/Form/NodeViewCountSettingsForm.php on line 123 in Drupal\nodeviewcount\Form\NodeViewCountSettingsForm->getRoleNamesOptions() (line 206 of modules/contrib/nodeviewcount/src/Form/NodeViewCountSettingsForm.php). 

when i go to /admin/config/content/nodeviewcount

nblack69’s picture

I get when I access "admin/config/content/nodeviewcount"
Drupal 9.5.3
Php 8.1.16

nblack69’s picture

I cannot make it work.. I don't know

nblack69’s picture

Don't understands... maybe because of Drupal or php?
Drupal 9.5.3 and php 8.1.16

shashank5563’s picture

I am able to reproduce the issue.

Message TypeError: Drupal\nodeviewcount\Form\NodeViewCountSettingsForm::getRoleNamesOptions(): Argument #1 ($excluded_user_roles) must be of type array, null given, called in /modules/contrib/nodeviewcount/src/Form/NodeViewCountSettingsForm.php on line 123 in Drupal\nodeviewcount\Form\NodeViewCountSettingsForm->getRoleNamesOptions() (line 206 of /modules/contrib/nodeviewcount/src/Form/NodeViewCountSettingsForm.php)

I am using following PHP,Drupal and db

Step to reproduce issue:
1. Following Configuration needed.
Drupal Version: 9.5.0
PHP Version: 8.1.9
Database Version: 10.8.3-MariaDB

2. I have install the module
3. Then try to access following URL: admin/config/content/nodeviewcount
4. Getting the issue.

shashank5563’s picture

StatusFileSize
new2.5 KB
new41.77 KB

@nblack69, I have made some changes in code. after fixing the code it is working fine.

shashank5563’s picture

Status: Active » Needs review
adci_contributor’s picture

Thank you for your help!

I was unable to repeat this problem with Drupal 9.5.11 and PHP 8.1.18. But everyone who has encountered the issue can try flush caches, uninstall and install the module again. If that doesn't help, this patch will be a good solution.

kostiantyn’s picture

On Drupal version: 10.2.3, MariaDB version: 10.4, and PHP version: 8.1, everything is working fine. I was able to reproduce the error on Drupal version 9.5.0, but the patch from @shashank5563 successfully resolves it.

kostiantyn’s picture

Status: Needs review » Reviewed & tested by the community

I tested the patch from @shashank5563 on Drupal 9.5.11. The error has disappeared.