Merge branch '8.0' into 8.1

* 8.0:
  Fix merge
  [WebProfiler] fix the security profiler template
  add tests for bypassed headers
  [Scheduler] Array to string conversion when using AsCronTask with array options
  the Serializer component does not work with PropertyInfo < 7.4
  [Config] Fix merging node that canBeDisable()/canBeEnabled()
  [ObjectMapper] error when multiple targets and no condition
This commit is contained in:
Nicolas Grekas
2026-01-10 14:59:01 +01:00
2 changed files with 8 additions and 3 deletions

View File

@@ -12,6 +12,7 @@
namespace Symfony\Component\Scheduler\DependencyInjection;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Messenger\RunCommandMessage;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -63,12 +64,14 @@ class AddScheduleMessengerPass implements CompilerPassInterface
if ($serviceDefinition->hasTag('console.command')) {
/** @var AsCommand|null $attribute */
$attribute = ($container->getReflectionClass($serviceDefinition->getClass())->getAttributes(AsCommand::class)[0] ?? null)?->newInstance();
$commandName = $attribute?->name;
if (\is_array($arguments = $tagAttributes['arguments'] ?? '')) {
$arguments = implode(' ', array_map(static fn (string $token) => preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token), $arguments));
$input = (string) new ArrayInput(['command' => $commandName, ...$arguments]);
} else {
$input = $commandName.('' !== $arguments ? " $arguments" : '');
}
$message = new Definition(RunCommandMessage::class, [$attribute?->name.('' !== $arguments ? " $arguments" : '')]);
$message = new Definition(RunCommandMessage::class, [$input]);
} else {
$message = new Definition(ServiceCallMessage::class, [$serviceId, $tagAttributes['method'] ?? '__invoke', (array) ($tagAttributes['arguments'] ?? [])]);
}

View File

@@ -54,6 +54,8 @@ class AddScheduleMessengerPassTest extends TestCase
yield 'array arguments' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => ['arg1', 'arg2']], 'schedulable arg1 arg2'];
yield 'array arguments with spaces' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => ['hello world', 'foo']], 'schedulable '.escapeshellarg('hello world').' foo'];
yield 'empty array arguments' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => []], 'schedulable'];
yield 'array options' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => ['--option1' => 'first', '--option2' => true, '--option3' => false]], 'schedulable --option1=first --option2=1 --option3'];
yield 'array arguments and options' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => ['arg1' => 'first_one', 'arg2' => 'second_one', '--option1' => 'first', '--option2' => true, '--option3' => false]], 'schedulable first_one second_one --option1=first --option2=1 --option3'];
}
}