Handler receives the envelope instead of the message it was registered for
還沒有人認領這個 Issue。
評估
研究方向
Read Worker.php, ConsumeFinalHandler.php, and the guide at docs/guide/en/messages-and-handlers.md:108; trace how IdEnvelope, DelayEnvelope, and FailureEnvelope move through the consume pipeline. First resolve the contract choice raised in the issue, especially alongside the #338 Worker and pipeline rework. Done means handlers receive the intended message or envelope contract consistently, with the guide and behavior agreeing.
由索引模型根據 Issue 內容生成。
描述
Worker::process() passes the message into the consume pipeline exactly as it arrived, and ConsumeFinalHandler hands that to the handler. Nothing unwraps an envelope on the way, so a handler written the way the guide writes it breaks as soon as the message is wrapped.
The documented handler (docs/guide/en/messages-and-handlers.md:108):
public function handle(MessageInterface $message): void
{
assert($message instanceof SendEmailMessage);
$this->mailer->send($message->to, $message->subject, $message->body);
}
Called with an adapter-assigned id, which is the normal asynchronous path:
$worker->process(new IdEnvelope($message, 'id-42'), 'test');
With zend.assertions=1:
MessageFailureException: Processing of message #id-42 is stopped because of an exception:
assert($message instanceof SendEmailMessage).
With zend.assertions=-1, the production default:
Warning: Undefined property: Yiisoft\Queue\Message\IdEnvelope::$to
sending to: NULL
No error, and the work is done against empty values. DelayEnvelope and FailureEnvelope behave the same way. Call path: Worker.php:45 → ConsumeMiddlewareDispatcher → ConsumeFinalHandler.php:21.
Worth deciding which contract is meant:
- unwrap in
Workerbefore dispatching, so a handler always receives the message type it was registered for, and offer the envelope separately to handlers that want the metadata, or - keep passing the envelope and change every handler example in the guide to unwrap first (
$message instanceof Envelope ? $message->getMessage() : $message), sinceassert()is not a guard in production.
InMemoryAdapter happens not to trigger this because it stores the unwrapped message, but any adapter that stores what push() returned does.
#338 reworks Worker and the pipeline around it, so this probably wants deciding before that lands.
- 主要語言
- PHP
- 星號
- 61
- 分支
- 31
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
yiisoft/queue 的其他 Issue
-
難度 5/5 一週以上 新手友好度 35/100
-
難度 5/5 一週以上 新手友好度 35/100
-
難度 4/5 1-2 天 新手友好度 47/100
-
難度 3/5 1-2 天 新手友好度 54/100
-
難度 4/5 3-5 天 新手友好度 45/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
-
Featured image not passed to checks in the Tasks column or publish blocks可能已有人在做 @roborourke 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
humanmade/publication-checklist#100 ·
維護者通常 1 天內回覆
-
bug customer-reported
難度 2/5 1-3 小時 新手友好度 62/100
MagnaCapax/PMSS#1072 ·
維護者通常 5 天內回覆
-
難度 2/5 半天 新手友好度 68/100
components-web-app/docs#244 ·
-
難度 2/5 1-3 小時 新手友好度 64/100
getgrav/grav-plugin-api#60 ·