The following error occurs if the Restrict By IP module is also installed:

TypeError: Drupal\block_class\Service\BlockClassHelperService::__construct(): Argument #10 ($currentUser) must be of type Drupal\Core\Session\AccountProxy, Drupal\restrict_by_ip\Session\AccountProxy given, called in /Users/dicksb/Sites/MAMP/moweb7/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 in Drupal\block_class\Service\BlockClassHelperService->__construct() (line 118 of modules/contrib/block_class/src/Service/BlockClassHelperService.php).

The attached patch replaces any uses of Drupal\Core\Session\AccountProxy with Drupal\Core\Session\AccountProxyInterface.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

wrd-oaitsd created an issue. See original summary.

kbentham’s picture

Status: Needs review » Reviewed & tested by the community

Tested this on a site that is on version 9.5.2 of Drupal, using version 4.0.0-beta1 of restrict_by_ip and it works great.

chris matthews’s picture

alex.bukach’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.35 KB

Re-rolled the patch.

dydave’s picture

Version: 2.0.x-dev » 4.0.x-dev

Porting patch to 4.0.x.

  • dydave committed 4c99a6ea on 4.0.x
    Issue #3293637 by wrd-oaitsd, alex.bukach, dydave: TypeError when...
dydave’s picture

Status: Needs review » Fixed

Sorry for the late reply on this issue and thank you very much everyone for the code contributions! 🙏

Just rolled in the patch from #4 into MR !70.

Since these changes had already been reviewed, tested and pending for a very long time, I went ahead and merged them above at #7 without further delay 😅

I wasn't able to test the changes myself manually though: I didn't try to install the module and reproduce the error and all...

But looking at the suggested changes from the patches, it made complete sense to replace a dependency on the class \Drupal\Core\Session\AccountProxy with the interface \Drupal\Core\Session\AccountProxyInterface.
This actually caught my attention when working on MR !67, when I reviewed all the properties of the BlockClassHelperService class to remove the unused ones.
I'm not sure why I hesitated and didn't make the change myself at this point... 😅
(perhaps it was a little "too" much in a single merge request 😅)

In any case, thank you very much for catching this one. 👍

Marking issue as Fixed, for now.

Feel free to let us know if you would have any questions or concerns on any aspects of the latest code changes or the module in general, we would surely be glad to hear your feedback. 😊
Thanks in advance!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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