10000 Merge branch '2.3' into 2.5 · symfony/symfony@5284b59 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5284b59

Browse files
committed
Merge branch '2.3' into 2.5
* 2.3: reformat code as suggested by @fabpot Fix typo Make `\Request::get` more performant. [FrameworkBundle] cache:clear command fills *.php.meta files with wrong data bumped Symfony version to 2.3.23 fixed typo updated VERSION for 2.3.22 update CONTRIBUTORS for 2.3.22 updated CHANGELOG for 2.3.22 Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
2 parents d88c60d + da1c1c5 commit 5284b59

File tree

6 files changed

+159
-2
lines changed

6 files changed

+159
-2
lines changed

CHANGELOG-2.3.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ in 2.3 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1
99

10+
* 2.3.22 (2014-11-20)
11+
12+
* bug #12525 [Bundle][FrameworkBundle] be smarter when guessing the document root (xabbuh)
13+
* bug #12296 [SecurityBundle] Authentication entry point is only registered with firewall exception listener, not with authentication listeners (rjkip)
14+
* bug #12393 [DependencyInjection] inlined factory not referenced (boekkooi)
15+
* bug #12436 [Filesystem] Fixed case for empty folder (yosmanyga)
16+
* bug #12370 [Yaml] improve error message for multiple documents (xabbuh)
17+
* bug #12170 [Form] fix form handling with OPTIONS request method (Tobion)
18+
* bug #12235 [Validator] Fixed Regex::getHtmlPattern() to work with complex and negated patterns (webmozart)
19+
* bug #12326 [Session] remove invalid hack in session regenerate (Tobion)
20+
* bug #12341 [Kernel] ensure session is saved before sending response (Tobion)
21+
* bug #12329 [Routing] serialize the compiled route to speed things up (Tobion)
22+
* bug #12316 Break infinite loop while resolving aliases (chx)
23+
* bug #12313 [Security][listener] change priority of switchuser (aitboudad)
24+
1025
* 2.3.21 (2014-10-24)
1126

1227
* bug #11696 [Form] Fix #11694 - Enforce options value type check in some form types (kix)

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
127127
$tempKernel = $this->getTempKernel($realKernel, $namespace, $realKernelClass, $warmupDir);
128128
$tempKernel->boot();
129129

130+
$tempKernelReflection = new \ReflectionObject($tempKernel);
131+
$tempKernelFile = $tempKernelReflection->getFileName();
132+
130133
// warmup temporary dir
131134
$warmer = $tempKernel->getContainer()->get('cache_warmer');
132135
if ($enableOptionalWarmers) {
@@ -162,6 +165,9 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
162165
file_put_contents(str_replace($search, $replace, $file), $content);
163166
unlink($file);
164167
}
168+
169+
// remove temp kernel file after cache warmed up
170+
@unlink($tempKernelFile);
165171
}
166172

167173
/**
@@ -201,13 +207,30 @@ public function getRootDir()
201207
{
202208
return '$rootDir';
203209
}
210+
211+
protected function buildContainer()
212+
{
213+
\$container = parent::buildContainer();
214+
215+
// filter container's resources, removing reference to temp kernel file
216+
\$resources = \$container->getResources();
217+
\$filteredResources = array();
218+
foreach (\$resources as \$resource) {
219+
if ((string) \$resource !== __FILE__) {
220+
\$filteredResources[] = \$resource;
221+
}
222+
}
223+
224+
\$container->setResources(\$filteredResources);
225+
226+
return \$container;
227+
}
204228
}
205229
}
206230
EOF;
207231
$this->getContainer()->get('filesystem')->mkdir($warmupDir);
208232
file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
209233
require_once $file;
210-
@unlink($file);
211234
$class = "$namespace\\$class";
212235

213236
return new $class($parent->getEnvironment(), $parent->isDebug());
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand;
4+
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture\TestAppKernel;
7+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
8+
use Symfony\Component\Config\ConfigCache;
9+
use Symfony\Component\Config\Resource\ResourceInterface;
10+
use Symfony\Component\Console\Input\ArrayInput;
11+
use Symfony\Component\Console\Output\NullOutput;
12+
use Symfony\Component\Filesystem\Filesystem;
13+
use Symfony\Component\Finder\Finder;
14+
15+
class CacheClearCommandTest extends TestCase
16+
{
17+
/** @var TestAppKernel */
18+
private $kernel;
19+
/** @var Filesystem */
20+
private $fs;
21+
private $rootDir;
22+
23+
protected function setUp()
24+
{
25+
$this->fs = new Filesystem();
26+
$this->kernel = new TestAppKernel('test', true);
27+
$this->rootDi F438 r = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_');
28+
$this->kernel->setRootDir($this->rootDir);
29+
$this->fs->mkdir($this->rootDir);
30+
}
31+
32+
protected function tearDown()
33+
{
34+
$this->fs->remove($this->rootDir);
35+
}
36+
37+
public function testCacheIsFreshAfterCacheClearedWithWarmup()
38+
{
39+
$input = new ArrayInput(array('cache:clear'));
40+
$application = new Application($this->kernel);
41+
$application->setCatchExceptions(false);
42+
43+
$application->doRun($input, new NullOutput());
44+
45+
// Ensure that all *.meta files are fresh
46+
$finder = new Finder();
47+
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
48+
// simply check that cache is warmed up
49+
$this->assertGreaterThanOrEqual(1, count($metaFiles));
50+
foreach ($metaFiles as $file) {
51+
$configCache = new ConfigCache(substr($file, 0, -5), true);
52+
$this->assertTrue(
53+
$configCache->isFresh(),
54+
sprintf(
55+
'Meta file "%s" is not fresh',
56+
(string) $file
57+
)
58+
);
59+
}
60+
61+
// check that app kernel file present in meta file of container's cache
62+
$containerRef = new \ReflectionObject($this->kernel->getContainer());
63+
$containerFile = $containerRef->getFileName();
64+
$containerMetaFile = $containerFile.'.meta';
65+
$kernelRef = new \ReflectionObject($this->kernel);
66+
$kernelFile = $kernelRef->getFileName();
67+
/** @var ResourceInterface[] $meta */
68+
$meta = unserialize(file_get_contents($containerMetaFile));
69+
$found = false;
70+
foreach ($meta as $resource) {
71+
if ((string) $resource === $kernelFile) {
72+
$found = true;
73+
break;
74+
}
75+
}
76+
$this->assertTrue($found, 'Kernel file should present as resource');
77+
}
78+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture;
4+
5+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
6+
use Symfony\Component\Config\Loader\LoaderInterface;
7+
use Symfony\Component\HttpKernel\Kernel;
8+
9+
class TestAppKernel extends Kernel
10+
{
11+
public function registerBundles()
12+
{
13+
return array(
14+
new FrameworkBundle(),
15+
);
16+
}
17+
18+
public function setRootDir($rootDir)
19+
{
20+
$this->rootDir = $rootDir;
21+
}
22+
23+
public function registerContainerConfiguration(LoaderInterface $loader)
24+
{
25+
$loader->load(__DIR__.DIRECTORY_SEPARATOR.'config.yml');
26+
}
27+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
framework:
2+
secret: test

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,19 @@ public static function getHttpMethodParameterOverride()
715715
*/
716716
public function get($key, $default = null, $deep = false)
717717
{
718-
return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default, $deep), $deep), $deep);
718+
if ($this !== $result = $this->query->get($key, $this, $deep)) {
719+
return $result;
720+
}
721+
722+
if ($this !== $result = $this->attributes->get($key, $this, $deep)) {
723+
return $result;
724+
}
725+
726+
if ($this !== $result = $this->request->get($key, $this, $deep)) {
727+
return $result;
728+
}
729+
730+
return $default;
719731
}
720732

721733
/**

0 commit comments

Comments
 (0)
0