Passing more extraParams to user spam checker from registration service requires overwriting whole method

Kirby

Well-known member
Affected version
2.2.12
\XF\Service\User\Registration::checkForSpam
PHP:
public function checkForSpam()
{
    $user = $this->user;

    $userChecker = $this->app->spam()->userChecker();
    $userChecker->check($user, ['preRegActionKey' => $this->preRegActionKey]);

Could this be changed so the second parameter for check is taken from a method istead of being hardcoded?

Eg. smth. like
PHP:
public function checkForSpam()
{
    $user = $this->user;

    $userChecker = $this->app->spam()->userChecker();
    $userChecker->check($user, $this->getSpamCheckExtraParams());

This would allow to easily pass more data through to the checker.
 
Sounds like a feature request/suggestion rather than a bug.
I'd have to dig it up but there has been a statement bei either Chris or Mike that code that does make extension more difficult than necessary should be reported as a bug.

Either way, why not hook straight into \XF\Spam\UserChecker::check
Because that method doesn't have access to the necessary data either (in a sane way) as it is downstream of the service and only the caller of the service has the data.

Sure, I could cheat and put the data somewhere else so the checker can access it (and probably combine it with extraParams) - but that doesn't feel clean :)
 
Last edited:
Top Bottom