Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Handler receives the envelope instead of the message it was registered for

Ouverte
#341 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
php
Domaine
api, backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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 Worker before 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), since assert() 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.

Langage dominant
PHP
Étoiles
61
Forks
31
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de yiisoft/queue

Toutes les issues de yiisoft/queue

Issues similaires

Plus d'issues PHP

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.