Skip to content

Commit 132afe6

Browse files
Merge branch '3.0'
* 3.0: [Process] Enhance compatiblity with --enable-sigchild [Validator] removes unused variable in LengthValidator class. [FrameworkBundle] [Bug] Fixes new InputStyle bug #16920 fix short array syntax for php 5.3 [Serializer] Fixed on array of objects in . [Process] Always call proc_close [Form] Add missing tests for StringUtil::fqcnToBlockPrefix() [Security] Fix a Polyfill import statement in StringUtils [Validator] Updated Luxembourgish translations for 2.8 Improved the code of the commands that use the new SymfonyStyle class disable server commands without Process component list all server command names in suggestion Suggested Process dependency disable server:run cmd without Process component Suggested Process dependency Fix DeprecationErrorHandler on PHP 5.3 [FrameworkBundle] prevent cache:clear creating too long paths [FrameworkBundle] [Translation] Fixed translations not written when no translations directory in update command
2 parents 4274c47 + cb0891a commit 132afe6

18 files changed

+125
-134
lines changed

Command/CacheClearCommand.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ protected function configure()
5555
protected function execute(InputInterface $input, OutputInterface $output)
5656
{
5757
$outputIsVerbose = $output->isVerbose();
58-
$output = new SymfonyStyle($input, $output);
58+
$io = new SymfonyStyle($input, $output);
5959

6060
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
61-
$oldCacheDir = $realCacheDir.'_old';
61+
// the old cache dir name must not be longer than the real one to avoid exceeding
62+
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
63+
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
6264
$filesystem = $this->getContainer()->get('filesystem');
6365

6466
if (!is_writable($realCacheDir)) {
@@ -70,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7072
}
7173

7274
$kernel = $this->getContainer()->get('kernel');
73-
$output->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
75+
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
7476
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
7577

7678
if ($input->getOption('no-warmup')) {
@@ -79,17 +81,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
7981
// the warmup cache dir name must have the same length than the real one
8082
// to avoid the many problems in serialized resources files
8183
$realCacheDir = realpath($realCacheDir);
82-
$warmupDir = substr($realCacheDir, 0, -1).'_';
84+
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
8385

8486
if ($filesystem->exists($warmupDir)) {
8587
if ($outputIsVerbose) {
86-
$output->comment('Clearing outdated warmup directory...');
88+
$io->comment('Clearing outdated warmup directory...');
8789
}
8890
$filesystem->remove($warmupDir);
8991
}
9092

9193
if ($outputIsVerbose) {
92-
$output->comment('Warming up cache...');
94+
$io->comment('Warming up cache...');
9395
}
9496
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
9597

@@ -101,16 +103,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
101103
}
102104

103105
if ($outputIsVerbose) {
104-
$output->comment('Removing old cache directory...');
106+
$io->comment('Removing old cache directory...');
105107
}
106108

107109
$filesystem->remove($oldCacheDir);
108110

109111
if ($outputIsVerbose) {
110-
$output->comment('Finished');
112+
$io->comment('Finished');
111113
}
112114

113-
$output->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
115+
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
114116
}
115117

116118
/**
@@ -120,8 +122,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
120122
*/
121123
protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = true)
122124
{
123-
$this->getContainer()->get('filesystem')->remove($warmupDir);
124-
125125
// create a temporary kernel
126126
$realKernel = $this->getContainer()->get('kernel');
127127
$realKernelClass = get_class($realKernel);

Command/CacheWarmupCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ protected function configure()
5454
*/
5555
protected function execute(InputInterface $input, OutputInterface $output)
5656
{
57-
$output = new SymfonyStyle($input, $output);
57+
$io = new SymfonyStyle($input, $output);
5858

5959
$kernel = $this->getContainer()->get('kernel');
60-
$output->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
60+
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
6161

6262
$warmer = $this->getContainer()->get('cache_warmer');
6363

@@ -67,6 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767

6868
$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));
6969

70-
$output->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
70+
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
7171
}
7272
}

Command/ConfigDebugCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ protected function configure()
5555
*/
5656
protected function execute(InputInterface $input, OutputInterface $output)
5757
{
58-
$output = new SymfonyStyle($input, $output);
58+
$io = new SymfonyStyle($input, $output);
5959
$name = $input->getArgument('name');
6060

6161
if (empty($name)) {
62-
$output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
63-
$output->newLine();
62+
$io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
63+
$io->newLine();
6464
$this->listBundles($output);
6565

6666
return;
@@ -80,12 +80,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
$config = $processor->processConfiguration($configuration, $configs);
8181

8282
if ($name === $extension->getAlias()) {
83-
$output->title(sprintf('Current configuration for extension with alias "%s"', $name));
83+
$io->title(sprintf('Current configuration for extension with alias "%s"', $name));
8484
} else {
85-
$output->title(sprintf('Current configuration for "%s"', $name));
85+
$io->title(sprintf('Current configuration for "%s"', $name));
8686
}
8787

88-
$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
88+
$io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
8989
}
9090

9191
private function compileContainer()

Command/ConfigDumpReferenceCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ protected function configure()
6767
*/
6868
protected function execute(InputInterface $input, OutputInterface $output)
6969
{
70-
$output = new SymfonyStyle($input, $output);
70+
$io = new SymfonyStyle($input, $output);
7171
$name = $input->getArgument('name');
7272

7373
if (empty($name)) {
74-
$output->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
75-
$output->newLine();
74+
$io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
75+
$io->newLine();
7676
$this->listBundles($output);
7777

7878
return;
@@ -92,18 +92,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
9292

9393
switch ($input->getOption('format')) {
9494
case 'yaml':
95-
$output->writeln(sprintf('# %s', $message));
95+
$io->writeln(sprintf('# %s', $message));
9696
$dumper = new YamlReferenceDumper();
9797
break;
9898
case 'xml':
99-
$output->writeln(sprintf('<!-- %s -->', $message));
99+
$io->writeln(sprintf('<!-- %s -->', $message));
100100
$dumper = new XmlReferenceDumper();
101101
break;
102102
default:
103-
$output->writeln($message);
103+
$io->writeln($message);
104104
throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
105105
}
106106

107-
$output->writeln($dumper->dump($configuration, $extension->getNamespace()));
107+
$io->writeln($dumper->dump($configuration, $extension->getNamespace()));
108108
}
109109
}

Command/ContainerDebugCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function configure()
9191
*/
9292
protected function execute(InputInterface $input, OutputInterface $output)
9393
{
94-
$output = new SymfonyStyle($input, $output);
94+
$io = new SymfonyStyle($input, $output);
9595
$this->validateInput($input);
9696

9797
if ($input->getOption('parameters')) {
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108
$options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
109109
} elseif ($name = $input->getArgument('name')) {
110110
$object = $this->getContainerBuilder();
111-
$name = $this->findProperServiceName($input, $output, $object, $name);
111+
$name = $this->findProperServiceName($input, $io, $object, $name);
112112
$options = array('id' => $name);
113113
} else {
114114
$object = $this->getContainerBuilder();
@@ -122,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
122122
$helper->describe($output, $object, $options);
123123

124124
if (!$input->getArgument('name') && $input->isInteractive()) {
125-
$output->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
125+
$io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
126126
}
127127
}
128128

@@ -181,7 +181,7 @@ protected function getContainerBuilder()
181181
return $this->containerBuilder = $container;
182182
}
183183

184-
private function findProperServiceName(InputInterface $input, SymfonyStyle $output, ContainerBuilder $builder, $name)
184+
private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, $name)
185185
{
186186
if ($builder->has($name) || !$input->isInteractive()) {
187187
return $name;
@@ -192,7 +192,7 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $outp
192192
throw new \InvalidArgumentException(sprintf('No services found that match "%s".', $name));
193193
}
194194

195-
return $output->choice('Select one of the following services to display its information', $matchingServices);
195+
return $io->choice('Select one of the following services to display its information', $matchingServices);
196196
}
197197

198198
private function findServiceIdsContaining(ContainerBuilder $builder, $name)

Command/EventDispatcherDebugCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ protected function configure()
5959
*/
6060
protected function execute(InputInterface $input, OutputInterface $output)
6161
{
62-
$output = new SymfonyStyle($input, $output);
62+
$io = new SymfonyStyle($input, $output);
6363
$dispatcher = $this->getEventDispatcher();
6464

6565
$options = array();
6666
if ($event = $input->getArgument('event')) {
6767
if (!$dispatcher->hasListeners($event)) {
68-
$output->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
68+
$io->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
6969

7070
return;
7171
}
@@ -76,8 +76,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7676
$helper = new DescriptorHelper();
7777
$options['format'] = $input->getOption('format');
7878
$options['raw_text'] = $input->getOption('raw');
79-
$options['output'] = $output;
80-
$helper->describe($output, $dispatcher, $options);
79+
$options['output'] = $io;
80+
$helper->describe($io, $dispatcher, $options);
8181
}
8282

8383
/**

Command/RouterDebugCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ protected function configure()
7575
*/
7676
protected function execute(InputInterface $input, OutputInterface $output)
7777
{
78-
$output = new SymfonyStyle($input, $output);
79-
78+
$io = new SymfonyStyle($input, $output);
8079
$name = $input->getArgument('name');
8180
$helper = new DescriptorHelper();
8281

@@ -88,11 +87,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
8887

8988
$this->convertController($route);
9089

91-
$helper->describe($output, $route, array(
90+
$helper->describe($io, $route, array(
9291
'format' => $input->getOption('format'),
9392
'raw_text' => $input->getOption('raw'),
9493
'name' => $name,
95-
'output' => $output,
94+
'output' => $io,
9695
));
9796
} else {
9897
$routes = $this->getContainer()->get('router')->getRouteCollection();
@@ -101,11 +100,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
101100
$this->convertController($route);
102101
}
103102

104-
$helper->describe($output, $routes, array(
103+
$helper->describe($io, $routes, array(
105104
'format' => $input->getOption('format'),
106105
'raw_text' => $input->getOption('raw'),
107106
'show_controllers' => $input->getOption('show-controllers'),
108-
'output' => $output,
107+
'output' => $io,
109108
));
110109
}
111110
}

Command/RouterMatchCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function configure()
7676
*/
7777
protected function execute(InputInterface $input, OutputInterface $output)
7878
{
79-
$output = new SymfonyStyle($input, $output);
79+
$io = new SymfonyStyle($input, $output);
8080

8181
$router = $this->getContainer()->get('router');
8282
$context = $router->getContext();
@@ -94,26 +94,26 @@ protected function execute(InputInterface $input, OutputInterface $output)
9494

9595
$traces = $matcher->getTraces($input->getArgument('path_info'));
9696

97-
$output->newLine();
97+
$io->newLine();
9898

9999
$matches = false;
100100
foreach ($traces as $trace) {
101101
if (TraceableUrlMatcher::ROUTE_ALMOST_MATCHES == $trace['level']) {
102-
$output->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
102+
$io->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
103103
} elseif (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) {
104-
$output->success(sprintf('Route "%s" matches', $trace['name']));
104+
$io->success(sprintf('Route "%s" matches', $trace['name']));
105105

106106
$routerDebugCommand = $this->getApplication()->find('debug:router');
107107
$routerDebugCommand->run(new ArrayInput(array('name' => $trace['name'])), $output);
108108

109109
$matches = true;
110110
} elseif ($input->getOption('verbose')) {
111-
$output->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
111+
$io->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
112112
}
113113
}
114114

115115
if (!$matches) {
116-
$output->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
116+
$io->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
117117

118118
return 1;
119119
}

Command/ServerCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public function isEnabled()
2727
return false;
2828
}
2929

30+
if (!class_exists('Symfony\Component\Process\Process')) {
31+
return false;
32+
}
33+
3034
return parent::isEnabled();
3135
}
3236

0 commit comments

Comments
 (0)