Skip to content

Commit f9fdb22

Browse files
Merge branch '3.4' into 4.0
* 3.4: Clean up Update return type in docblock. PHP CS Fixer: no need to exclude xml and yml files PHP CS Fixer: no need to exclude json file Update LICENSE year... forever fixed some deprecation messages fixed CS Fixes for Oracle in PdoSessionHandler fixed some deprecation messages fixed some deprecation messages fixed some deprecation messages fixed some deprecation messages [TwigBundle/Brige] catch missing requirements to throw meaningful exceptions [HttpKernel] Call Response->setPrivate() instead of sending raw header() when session is started [FrameworkBundle] Make cache:clear "atomic" and consistent with cache:warmup Suggest to write an implementation if the interface cannot be autowired [Debug] Skip DebugClassLoader checks for already parsed files [2.7][DX] Use constant message contextualisation for deprecations Remove group options without data and fix normalization Remove redundant translation path
2 parents 546ca41 + dd66512 commit f9fdb22

File tree

74 files changed

+496
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+496
-179
lines changed

.php_cs.dist

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,9 @@ return PhpCsFixer\Config::create()
3232
))
3333
// file content autogenerated by `var_export`
3434
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
35-
// autogenerated xmls
36-
->notPath('Symfony/Component/Console/Tests/Fixtures/application_1.xml')
37-
->notPath('Symfony/Component/Console/Tests/Fixtures/application_2.xml')
38-
// yml
39-
->notPath('Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml')
4035
// test template
4136
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
4237
// explicit heredoc test
4338
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
44-
// purposefully invalid JSON
45-
->notPath('Symfony/Component/Asset/Tests/fixtures/manifest-invalid.json')
4639
)
4740
;

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2017 Fabien Potencier
1+
Copyright (c) 2004-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bridge/Doctrine/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2017 Fabien Potencier
1+
Copyright (c) 2004-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bridge/Monolog/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2017 Fabien Potencier
1+
Copyright (c) 2004-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bridge/PhpUnit/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2017 Fabien Potencier
1+
Copyright (c) 2014-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bridge/ProxyManager/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2017 Fabien Potencier
1+
Copyright (c) 2004-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bridge/Twig/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2017 Fabien Potencier
1+
Copyright (c) 2004-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Twig;
13+
14+
use Twig\Error\SyntaxError;
15+
16+
/**
17+
* @internal
18+
*/
19+
class UndefinedCallableHandler
20+
{
21+
private static $filterComponents = array(
22+
'humanize' => 'form',
23+
'trans' => 'translation',
24+
'transchoice' => 'translation',
25+
'yaml_encode' => 'yaml',
26+
'yaml_dump' => 'yaml',
27+
);
28+
29+
private static $functionComponents = array(
30+
'asset' => 'asset',
31+
'asset_version' => 'asset',
32+
'dump' => 'debug-bundle',
33+
'expression' => 'expression-language',
34+
'form_widget' => 'form',
35+
'form_errors' => 'form',
36+
'form_label' => 'form',
37+
'form_row' => 'form',
38+
'form_rest' => 'form',
39+
'form' => 'form',
40+
'form_start' => 'form',
41+
'form_end' => 'form',
42+
'csrf_token' => 'form',
43+
'logout_url' => 'security-http',
44+
'logout_path' => 'security-http',
45+
'is_granted' => 'security-core',
46+
'link' => 'web-link',
47+
'preload' => 'web-link',
48+
'dns_prefetch' => 'web-link',
49+
'preconnect' => 'web-link',
50+
'prefetch' => 'web-link',
51+
'prerender' => 'web-link',
52+
'workflow_can' => 'workflow',
53+
'workflow_transitions' => 'workflow',
54+
'workflow_has_marked_place' => 'workflow',
55+
'workflow_marked_places' => 'workflow',
56+
);
57+
58+
public static function onUndefinedFilter($name)
59+
{
60+
if (!isset(self::$filterComponents[$name])) {
61+
return false;
62+
}
63+
64+
// Twig will append the source context to the message, so that it will end up being like "[...] Unknown filter "%s" in foo.html.twig on line 123."
65+
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown filter "%s".', $name, self::$filterComponents[$name]));
66+
}
67+
68+
public static function onUndefinedFunction($name)
69+
{
70+
if (!isset(self::$functionComponents[$name])) {
71+
return false;
72+
}
73+
74+
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown function "%s".', $name, self::$functionComponents[$name]));
75+
}
76+
}

src/Symfony/Bundle/DebugBundle/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014-2017 Fabien Potencier
1+
Copyright (c) 2014-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -73,40 +73,62 @@ protected function configure()
7373
*/
7474
protected function execute(InputInterface $input, OutputInterface $output)
7575
{
76+
$fs = $this->filesystem;
7677
$io = new SymfonyStyle($input, $output);
7778

7879
$kernel = $this->getApplication()->getKernel();
7980
$realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
8081
// the old cache dir name must not be longer than the real one to avoid exceeding
8182
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
8283
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
84+
$fs->remove($oldCacheDir);
8385

8486
if (!is_writable($realCacheDir)) {
8587
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
8688
}
8789

88-
if ($this->filesystem->exists($oldCacheDir)) {
89-
$this->filesystem->remove($oldCacheDir);
90-
}
91-
9290
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
9391
$this->cacheClearer->clear($realCacheDir);
9492

9593
// The current event dispatcher is stale, let's not use it anymore
9694
$this->getApplication()->setDispatcher(new EventDispatcher());
9795

98-
if ($input->getOption('no-warmup')) {
99-
$this->filesystem->rename($realCacheDir, $oldCacheDir);
100-
} else {
101-
$this->warmupCache($input, $output, $realCacheDir, $oldCacheDir);
96+
$containerDir = new \ReflectionObject($kernel->getContainer());
97+
$containerDir = basename(dirname($containerDir->getFileName()));
98+
99+
// the warmup cache dir name must have the same length as the real one
100+
// to avoid the many problems in serialized resources files
101+
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
102+
103+
if ($output->isVerbose() && $fs->exists($warmupDir)) {
104+
$io->comment('Clearing outdated warmup directory...');
105+
}
106+
$fs->remove($warmupDir);
107+
$fs->mkdir($warmupDir);
108+
109+
if (!$input->getOption('no-warmup')) {
110+
if ($output->isVerbose()) {
111+
$io->comment('Warming up cache...');
112+
}
113+
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
114+
}
115+
116+
$containerDir = $fs->exists($warmupDir.'/'.$containerDir) ? false : $containerDir;
117+
118+
$fs->rename($realCacheDir, $oldCacheDir);
119+
$fs->rename($warmupDir, $realCacheDir);
120+
121+
if ($containerDir) {
122+
$fs->rename($oldCacheDir.'/'.$containerDir, $realCacheDir.'/'.$containerDir);
123+
touch($realCacheDir.'/'.$containerDir.'.legacy');
102124
}
103125

104126
if ($output->isVerbose()) {
105127
$io->comment('Removing old cache directory...');
106128
}
107129

108130
try {
109-
$this->filesystem->remove($oldCacheDir);
131+
$fs->remove($oldCacheDir);
110132
} catch (IOException $e) {
111133
$io->warning($e->getMessage());
112134
}
@@ -118,34 +140,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
118140
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
119141
}
120142

121-
private function warmupCache(InputInterface $input, OutputInterface $output, string $realCacheDir, string $oldCacheDir)
122-
{
123-
$io = new SymfonyStyle($input, $output);
124-
125-
// the warmup cache dir name must have the same length than the real one
126-
// to avoid the many problems in serialized resources files
127-
$realCacheDir = realpath($realCacheDir);
128-
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
129-
130-
if ($this->filesystem->exists($warmupDir)) {
131-
if ($output->isVerbose()) {
132-
$io->comment('Clearing outdated warmup directory...');
133-
}
134-
$this->filesystem->remove($warmupDir);
135-
}
136-
137-
if ($output->isVerbose()) {
138-
$io->comment('Warming up cache...');
139-
}
140-
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
141-
142-
$this->filesystem->rename($realCacheDir, $oldCacheDir);
143-
if ('\\' === DIRECTORY_SEPARATOR) {
144-
sleep(1); // workaround for Windows PHP rename bug
145-
}
146-
$this->filesystem->rename($warmupDir, $realCacheDir);
147-
}
148-
149143
private function warmup(string $warmupDir, string $realCacheDir, bool $enableOptionalWarmers = true)
150144
{
151145
// create a temporary kernel

0 commit comments

Comments
 (0)