Skip to content

[Messenger] messenger:failed:remove can not remove single message #36659

@tienvx

Description

@tienvx

Symfony version(s) affected: 5.1-dev

Description
If we pass single id to messenger:failed:remove command, this error happen:

In FailedMessagesRemoveCommand.php line 65:

  count(): Parameter must be an array or an object that implements Countable 

messenger:failed:remove [--force] [--show-messages] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <id>...

How to reproduce

$application = new Application($this->kernel);
$application->setAutoExit(false);

$output = new BufferedOutput();
$code = $application->run(new ArrayInput([
    'command' => 'messenger:failed:remove',
    'id' => $id,
    '--force' => true,
]), $output);

dump($output->fetch());

Possible Solution
Cast id argument to array:

$ids = (array) $input->getArgument('id');

Additional context

This error happen with CommandTester also:

$command = new FailedMessagesRemoveCommand(
    'failure_receiver',
    $receiver
);

$tester = new CommandTester($command);
$tester->execute(['id' => 20, '--force' => true]);

But this error does not happen if I run command from command line:

tests/app/bin/console messenger:failed:remove 1 --force

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions