Skip to content

fix: add console request check to EVENT_BEFORE_SEND handler#45

Merged
jaymeh merged 1 commit into
creode:4.xfrom
dgrigg:4.x
Apr 2, 2026
Merged

fix: add console request check to EVENT_BEFORE_SEND handler#45
jaymeh merged 1 commit into
creode:4.xfrom
dgrigg:4.x

Conversation

@dgrigg

@dgrigg dgrigg commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a console request check in the Mailer::EVENT_BEFORE_SEND handler to skip getBodyParam() calls in CLI/queue context

Problem

The EVENT_BEFORE_SEND handler at MagicLogin.php:156 calls $this->request->getBodyParam('magicLoginRegistration') on every email sent. When emails are sent from queue jobs (e.g., Formie notifications), the request is craft\console\Request which doesn't have getBodyParam(), causing:

yii\base\UnknownMethodException: Calling unknown method: craft\console\Request::getBodyParam()

This breaks all queued email notifications from any plugin (Formie, etc).

Fix

Added a getIsConsoleRequest() check before calling getBodyParam(). In console context the handler returns early — the magic login registration check is only relevant during web requests anyway.

Fixes #44

The Mailer EVENT_BEFORE_SEND handler calls getBodyParam() which only
exists on craft\web\Request. When emails are sent from queue jobs
(console context), this crashes with UnknownMethodException.

Adds a console request check to skip the handler in CLI context,
fixing compatibility with plugins like Formie that send emails
via queue jobs.

Fixes creode#44
@creode-dev creode-dev changed the title Fix: add console request check to EVENT_BEFORE_SEND handler fix: add console request check to EVENT_BEFORE_SEND handler Apr 2, 2026
@jaymeh

jaymeh commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution and detailed issue log for this one. I'll merge this in now and push a new release.

@jaymeh jaymeh merged commit eb4da24 into creode:4.x Apr 2, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mailer EVENT_BEFORE_SEND handler crashes in console/queue context

2 participants