Skip to content

Commit

Permalink
Bugfix: when anonymous commands have same arguments, container fails …
Browse files Browse the repository at this point in the history
…as their md5 hash is the same
  • Loading branch information
foglcz committed Jan 19, 2016
1 parent d4f6edd commit 0fb546c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Kdyby/Console/DI/ConsoleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public function loadConfiguration()
}

Nette\Utils\Validators::assert($config, 'array');
foreach ($config['commands'] as $command) {
$def = $builder->addDefinition($this->prefix('command.' . md5(Nette\Utils\Json::encode($command))));
foreach ($config['commands'] as $i => $command) {
$def = $builder->addDefinition($this->prefix('command.' . $i));
list($def->factory) = Nette\DI\Compiler::filterArguments(array(
is_string($command) ? new Statement($command) : $command
));
Expand Down
46 changes: 46 additions & 0 deletions tests/KdybyTests/Console/InputErrors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,52 @@ class TypoCommand extends Symfony\Component\Console\Command\Command



protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
}

}

class SameArgsCommandOne extends Symfony\Component\Console\Command\Command
{

public function __construct(ArgCommand $argCommand, TypoCommand $typoCommand)
{
parent::__construct();
}


protected function configure()
{
$this->setName('sameArgsCommand:one');
}



protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
}

}


class SameArgsCommandTwo extends Symfony\Component\Console\Command\Command
{

public function __construct(ArgCommand $argCommand, TypoCommand $typoCommand)
{
parent::__construct();
}

protected function configure()
{
$this->setName('sameArgsCommand:two');
}



protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/config/input-errors.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ console:
- KdybyTests\Console\NamespaceAmbiguousCommand1
- KdybyTests\Console\NamespaceAmbiguousCommand2
- KdybyTests\Console\ArgCommand
- KdybyTests\Console\SameArgsCommandOne(@service1, @service2)
- KdybyTests\Console\SameArgsCommandTwo(@service1, @service2)

services:
service1: KdybyTests\Console\ArgCommand
service2: KdybyTests\Console\TypoCommand

3 comments on commit 0fb546c

@janedbal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fprochazka When can I expect stable tag with this bugfix?

@fprochazka
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janedbal I will do my best to release it soon

@janedbal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fprochazka Reminding stable tag request :)

Please sign in to comment.