Skip to content

Commit 61bd29e

Browse files
committed
#23354 Add $kernel->getTmpDir() to separate it from the cache directory
1 parent 01794d0 commit 61bd29e

File tree

18 files changed

+40
-15
lines changed

18 files changed

+40
-15
lines changed

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ protected function createContainer(array $data = []): ContainerBuilder
263263
return new ContainerBuilder(new ParameterBag(array_merge([
264264
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
265265
'kernel.cache_dir' => __DIR__,
266+
'kernel.tmp_dir' => __DIR__,
266267
'kernel.container_class' => 'kernel',
267268
'kernel.project_dir' => __DIR__,
268269
], $data)));

src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private function createContainer()
7474
{
7575
$container = new ContainerBuilder(new ParameterBag([
7676
'kernel.cache_dir' => __DIR__,
77+
'kernel.tmp_dir' => __DIR__,
7778
'kernel.charset' => 'UTF-8',
7879
'kernel.debug' => true,
7980
'kernel.bundles' => ['DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'],

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7676
['Debug', $kernel->isDebug() ? 'true' : 'false'],
7777
['Charset', $kernel->getCharset()],
7878
['Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'],
79+
['Temp directory', self::formatPath($kernel->getTmpDir(), $kernel->getTmpDir()).' (<comment>'.self::formatFileSize($kernel->getTmpDir()).'</>)'],
7980
['Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'],
8081
new TableSeparator(),
8182
['<info>PHP</>'],

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8080

8181
$kernel = $this->getApplication()->getKernel();
8282
$realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
83+
$realTmpDir = $kernel->getContainer()->getParameter('kernel.tmp_dir');
8384
// the old cache dir name must not be longer than the real one to avoid exceeding
8485
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
8586
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
86-
$fs->remove($oldCacheDir);
87+
$oldTmpDir = substr($realTmpDir, 0, -1).('~' === substr($realTmpDir, -1) ? '+' : '~');
88+
$fs->remove([$oldCacheDir, $oldTmpDir]);
8789

8890
if (!is_writable($realCacheDir)) {
8991
throw new RuntimeException(sprintf('Unable to write in the "%s" directory.', $realCacheDir));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8585

8686
foreach ($clearers as $id => $clearer) {
8787
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
88-
$clearer->clear($kernel->getContainer()->getParameter('kernel.cache_dir'));
88+
$clearer->clear($kernel->getContainer()->getParameter('kernel.tmp_dir'));
8989
}
9090

9191
foreach ($pools as $id => $pool) {

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode)
230230
->booleanNode('collect')->defaultTrue()->end()
231231
->booleanNode('only_exceptions')->defaultFalse()->end()
232232
->booleanNode('only_master_requests')->defaultFalse()->end()
233-
->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
233+
->scalarNode('dsn')->defaultValue('file:%kernel.tmp_dir%/profiler')->end()
234234
->end()
235235
->end()
236236
->end()
@@ -527,7 +527,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
527527
->scalarNode('gc_divisor')->end()
528528
->scalarNode('gc_probability')->defaultValue(1)->end()
529529
->scalarNode('gc_maxlifetime')->end()
530-
->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
530+
->scalarNode('save_path')->defaultValue('%kernel.tmp_dir%/sessions')->end()
531531
->integerNode('metadata_update_threshold')
532532
->defaultValue(0)
533533
->info('seconds to wait between 2 session metadata updates')
@@ -881,7 +881,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
881881
->info('System related cache pools configuration')
882882
->defaultValue('cache.adapter.system')
883883
->end()
884-
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools')->end()
884+
->scalarNode('directory')->defaultValue('%kernel.tmp_dir%/pools')->end()
885885
->scalarNode('default_doctrine_provider')->end()
886886
->scalarNode('default_psr6_provider')->end()
887887
->scalarNode('default_redis_provider')->defaultValue('redis://localhost')->end()

src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ protected function createSurrogate()
7474

7575
protected function createStore()
7676
{
77-
return new Store($this->cacheDir ?: $this->kernel->getCacheDir().'/http_cache');
77+
return new Store($this->cacheDir ?: $this->kernel->getTmpDir().'/http_cache');
7878
}
7979
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<argument /> <!-- namespace -->
4747
<argument>0</argument> <!-- default lifetime -->
4848
<argument /> <!-- version -->
49-
<argument>%kernel.cache_dir%/pools</argument>
49+
<argument>%kernel.tmp_dir%/pools</argument>
5050
<argument type="service" id="logger" on-invalid="ignore" />
5151
</service>
5252

@@ -77,7 +77,7 @@
7777
<tag name="monolog.logger" channel="cache" />
7878
<argument /> <!-- namespace -->
7979
<argument>0</argument> <!-- default lifetime -->
80-
<argument>%kernel.cache_dir%/pools</argument>
80+
<argument>%kernel.tmp_dir%/pools</argument>
8181
<argument type="service" id="cache.default_marshaller" on-invalid="ignore" />
8282
<call method="setLogger">
8383
<argument type="service" id="logger" on-invalid="ignore" />

src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<tag name="data_collector" template="@WebProfiler/Collector/logger.html.twig" id="logger" priority="300" />
3636
<tag name="monolog.logger" channel="profiler" />
3737
<argument type="service" id="logger" on-invalid="ignore" />
38-
<argument>%kernel.cache_dir%/%kernel.container_class%</argument>
38+
<argument>%kernel.tmp_dir%/%kernel.container_class%</argument>
3939
<argument type="service" id="request_stack" on-invalid="ignore" />
4040
</service>
4141

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</service>
5454

5555
<service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage">
56-
<argument>%kernel.cache_dir%/sessions</argument>
56+
<argument>%kernel.tmp_dir%/sessions</argument>
5757
<argument>MOCKSESSID</argument>
5858
<argument type="service" id="session.storage.metadata_bag" />
5959
</service>

0 commit comments

Comments
 (0)