8000 Merge branch '4.0' · symfony/symfony@2ca8657 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ca8657

Browse files
Merge branch '4.0'
* 4.0: (32 commits) [Form] fix tests and deps [Cache] Rely on mock for Doctrine ArrayCache [FrameworkBundle] Respect debug mode when warm up annotations [Console] Fix docblock of DescriptorInterface::describe [Config] Handle nullable node name + fix inheritdocs [Security] added userChecker to SimpleAuthenticationProvider [Debug] fix test Fix typo in test method name Fixes #26563 (open_basedir restriction in effect) [Debug] Reset previous exception handler ealier to prevent infinite loop add hint in Github pull request template [Validator] Fix docblock of ClassMetadata#members [BrowserKit] Fix cookie path handling when $domain is null [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore [BrowserKit] Improves CookieJar::get [BrowserKit] Fix Cookie's PHPDoc [DomCrawler] Change bad wording in ChoiceFormField::untick [DomCrawler] Fix the PHPDoc of ChoiceFormField::setValue [DomCrawler] Avoid a useless call to strtolower [FrameworkBundle] HttpCache is not longer abstract ...
2 parents 4cc8cf6 + 1f119cc commit 2ca8657

File tree

48 files changed

+494
-165
lines changed

Some content is hidden

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

48 files changed

+494
-165
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| Bug fix? | yes/no
55
| New feature? | yes/no <!-- don't forget to update src/**/CHANGELOG.md files -->
66
| BC breaks? | no <!-- see https://symfony.com/bc -->
7-
| Deprecations? | yes/no <!-- don't forget to update UPGRADE-*.md files -->
7+
| Deprecations? | yes/no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
88
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
99
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
1010
| License | MIT

CONTRIBUTORS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ Symfony is the result of the work of many people who made the code better
4343
- Diego Saint Esteben (dosten)
4444
- Alexandre Salomé (alexandresalome)
4545
- William Durand (couac)
46+
- Hamza Amrouche (simperfit)
4647
- ornicar
4748
- Francis Besset (francisbesset)
4849
- Iltar van der Berg (kjarli)
4950
- stealth35 ‏ (stealth35)
50-
- Hamza Amrouche (simperfit)
5151
- Alexander Mols (asm89)
5252
- Yonel Ceruto (yonelceruto)
5353
- Bulat Shakirzyanov (avalanche123)
@@ -57,15 +57,16 @@ Symfony is the result of the work of many people who made the code better
5757
- Henrik Bjørnskov (henrikbjorn)
5858
- Miha Vrhovnik
5959
- Diego Saint Esteben (dii3g0)
60-
- Dany Maillard (maidmaid)
6160
- Pierre du Plessis (pierredup)
61+
- Dany Maillard (maidmaid)
6262
- Konstantin Kudryashov (everzet)
6363
- Kevin Bond (kbond)
6464
- Bilal Amarni (bamarni)
6565
- Alexander M. Turek (derrabus)
6666
- Jérémy DERUSSÉ (jderusse)
6767
- Florin Patan (florinpatan)
6868
- Samuel ROZE (sroze)
69+
- Tobias Nyholm (tobias)
6970
- Gábor Egyed (1ed)
7071
- Michel Weimerskirch (mweimerskirch)
7172
- Andrej Hudec (pulzarraider)
@@ -75,7 +76,6 @@ Symfony is the result of the work of many people who made the code better
7576
- Titouan Galopin (tgalopin)
7677
- Konstantin Myakshin (koc)
7778
- Christian Raue
78-
- Tobias Nyholm (tobias)
7979
- Arnout Boks (aboks)
8080
- Deni
8181
- Henrik Westphal (snc)
@@ -200,6 +200,7 @@ Symfony is the result of the work of many people who made the code better
200200
- Matthieu Bontemps (mbontemps)
201201
- apetitpa
202202
- Pierre Minnieur (pminnieur)
203+
- Jannik Zschiesche (apfelbox)
203204
- fivestar
204205
- Dominique Bongiraud
205206
- Jeremy Livingston (jeremylivingston)
@@ -224,7 +225,6 @@ Symfony is the result of the work of many people who made the code better
224225
- Marcel Beerta (mazen)
225226
- gadelat (gadelat)
226227
- Loïc Faugeron
227-
- Jannik Zschiesche (apfelbox)
228228
- Hidde Wieringa (hiddewie)
229229
- Marco Pivetta (ocramius)
230230
- Rob Frawley 2nd (robfrawley)
@@ -697,6 +697,7 @@ Symfony is the result of the work of many people who made the code better
697697
- Nykopol (nykopol)
698698
- Jordan Deitch
699699
- Casper Valdemar Poulsen
700+
- Remon van de Kamp
700701
- Josiah (josiah)
701702
- Joschi Kuphal
702703
- John Bohn (jbohn)
@@ -736,6 +737,7 @@ Symfony is the result of the work of many people who made the code better
736737
- Adrien Lucas (adrienlucas)
737738
- Zhuravlev Alexander (scif)
738739
- James Michael DuPont
740+
- Xavier HAUSHERR
739741
- Tom Klingenberg
740742
- Christopher Hall (mythmakr)
741743
- Patrick Dawkins (pjcdawkins)
@@ -1102,7 +1104,6 @@ Symfony is the result of the work of many people who made the code better
11021104
- Pierre Tachoire (krichprollsch)
11031105
- Marc J. Schmidt (marcjs)
11041106
- Marco Jantke
1105-
- Remon van de Kamp
11061107
- Saem Ghani
11071108
- Clément LEFEBVRE
11081109
- Conrad Kleinespel
@@ -1225,7 +1226,6 @@ Symfony is the result of the work of many people who made the code better
12251226
- Sebastian Ionescu
12261227
- Thomas Ploch
12271228
- Simon Neidhold
1228-
- Xavier HAUSHERR
12291229
- Valentin VALCIU
12301230
- Jeremiah VALERIE
12311231
- Kevin Dew
@@ -1573,6 +1573,7 @@ Symfony is the result of the work of many people who made the code better
15731573
- Vladimir Chernyshev (volch)
15741574
- Yorkie Chadwick (yorkie76)
15751575
- GuillaumeVerdon
1576+
- Philipp Keck
15761577
- Ondrej Mirtes
15771578
- akimsko
15781579
- Youpie
@@ -1630,6 +1631,7 @@ Symfony is the result of the work of many people who made the code better
16301631
- Jordan Hoff
16311632
- znerol
16321633
- Christian Eikermann
1634+
- Kai Eichinger
16331635
- Antonio Angelino
16341636
- Matt Fields
16351637
- Niklas Keller

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<element><string>Cache\IntegrationTests</string></element>
6666
<element><string>Doctrine\Common\Cache</string></element>
6767
<element><string>Symfony\Component\Cache</string></element>
68+
<element><string>Symfony\Component\Cache\Tests\Fixtures</string></element>
6869
<element><string>Symfony\Component\Cache\Traits</string></element>
6970
<element><string>Symfony\Component\Console</string></element>
7071
<element><string>Symfony\Component\HttpFoundation</string></element>

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function guessRequired($class, $property)
104104
$classMetadata = $classMetadatas[0];
105105

106106
// Check whether the field exists and is nullable or not
107-
if ($classMetadata->hasField($property)) {
107+
if (isset($classMetadata->fieldMappings[$property])) {
108108
if (!$classMetadata->isNullable($property) && Type::BOOLEAN !== $classMetadata->getTypeOfField($property)) {
109109
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
110110
}
@@ -133,7 +133,7 @@ public function guessRequired($class, $property)
133133
public function guessMaxLength($class, $property)
134134
{
135135
$ret = $this->getMetadata($class);
136-
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
136+
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
137137
$mapping = $ret[0]->getFieldMapping($property);
138138

139139
if (isset($mapping['length'])) {
@@ -152,7 +152,7 @@ public function guessMaxLength($class, $property)
152152
public function guessPattern($class, $property)
153153
{
154154
$ret = $this->getMetadata($class);
155-
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
155+
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
156156
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
157157
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
158158
}

src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@ public function requiredProvider()
3333

3434
// Simple field, not nullable
3535
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
36-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true));
36+
$classMetadata->fieldMappings['field'] = true;
3737
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false));
3838

3939
$return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE));
4040

4141
// Simple field, nullable
4242
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
43-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(true));
43+
$classMetadata->fieldMappings['field'] = true;
4444
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true));
4545

4646
$return[] = array($classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE));
4747

4848
// One-to-one, nullable (by default)
4949
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
50-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
5150
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
5251

5352
$mapping = array('joinColumns' => array(array()));
@@ -57,7 +56,6 @@ public function requiredProvider()
5756

5857
// One-to-one, nullable (explicit)
5958
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
60-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
6159
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
6260

6361
$mapping = array('joinColumns' => array(array('nullable' => true)));
@@ -67,7 +65,6 @@ public function requiredProvider()
6765

6866
// One-to-one, not nullable
6967
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
70-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
7168
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
7269

7370
$mapping = array('joinColumns' => array(array('nullable' => false)));
@@ -77,7 +74,6 @@ public function requiredProvider()
7774

7875
// One-to-many, no clue
7976
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
80-
$classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false));
8177
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false));
8278

8379
$return[] = array($classMetadata, null);

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public function __construct(Environment $twig)
5454
*/
5555
public function extract($resource, MessageCatalogue $catalogue)
5656
{
57-
$files = $this->extractFiles($resource);
58-
foreach ($files as $file) {
57+
foreach ($this->extractFiles($resource) as $file) {
5958
try {
6059
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
6160
} catch (Error $e) {

src/Symfony/Bridge/Twig/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/asset": "~3.4|~4.0",
2424
"symfony/dependency-injection": "~3.4|~4.0",
2525
"symfony/finder": "~3.4|~4.0",
26-
"symfony/form": "^3.4.5|^4.0.5",
26+
"symfony/form": "^3.4.7|^4.0.7",
2727
"symfony/http-foundation": "~3.4|~4.0",
2828
"symfony/http-kernel": "~3.4|~4.0",
2929
"symfony/polyfill-intl-icu": "~1.0",
@@ -41,7 +41,7 @@
4141
"symfony/workflow": "~3.4|~4.0"
4242
},
4343
"conflict": {
44-
"symfony/form": "<3.4.5|<4.0.5,>=4.0",
44+
"symfony/form": "<3.4.7|<4.0.7,>=4.0",
4545
"symfony/console": "<3.4"
4646
},
4747
"suggest": {

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
2828
{
2929
private $annotationReader;
3030
private $excludeRegexp;
31+
private $debug;
3132

3233
/**
3334
* @param Reader $annotationReader
3435
* @param string $phpArrayFile The PHP file where annotations are cached
3536
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached
3637
*/
37-
public function __construct(Reader $annotationReader, string $phpArrayFile, CacheItemPoolInterface $fallbackPool, string $excludeRegexp = null)
38+
public function __construct(Reader $annotationReader, string $phpArrayFile, CacheItemPoolInterface $fallbackPool, string $excludeRegexp = null, bool $debug = false)
3839
{
3940
parent::__construct($phpArrayFile, $fallbackPool);
4041
$this->annotationReader = $annotationReader;
4142
$this->excludeRegexp = $excludeRegexp;
43+
$this->debug = $debug;
4244
}
4345

4446
/**
@@ -53,7 +55,7 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
5355
}
5456

5557
$annotatedClasses = include $annotatedClassPatterns;
56-
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter));
58+
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug);
5759

5860
foreach ($annotatedClasses as $class) {
5961
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\HttpCache;
1313

14-
use Symfony\Component\HttpKernel\HttpKernelInterface;
14+
use Symfony\Component\HttpKernel\KernelInterface;
1515
use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache;
1616
use Symfony\Component\HttpKernel\HttpCache\Esi;
1717
use Symfony\Component\HttpKernel\HttpCache\Store;
@@ -23,16 +23,16 @@
2323
*
2424
* @author Fabien Potencier <fabien@symfony.com>
2525
*/
26-
abstract class HttpCache extends BaseHttpCache
26+
class HttpCache extends BaseHttpCache
2727
{
2828
protected $cacheDir;
2929
protected $kernel;
3030

3131
/**
32-
* @param HttpKernelInterface $kernel An HttpKernelInterface instance
33-
* @param string $cacheDir The cache directory (default used if null)
32+
* @param KernelInterface $kernel A KernelInterface instance
33+
* @param string $cacheDir The cache directory (default used if null)
3434
*/
35-
public function __construct(HttpKernelInterface $kernel, string $cacheDir = null)
35+
public function __construct(KernelInterface $kernel, string $cacheDir = null)
3636
{
3737
$this->kernel = $kernel;
3838
$this->cacheDir = $cacheDir;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<argument>%kernel.cache_dir%/annotations.php</argument>
3939
<argument type="service" id="cache.annotations" />
4040
<argument>#^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))#</argument>
41+
<argument>%kernel.debug%</argument>
4142
</service>
4243

4344
<service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider">
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
4+
5+
use Doctrine\Common\Annotations\AnnotationReader;
6+
use Doctrine\Common\Annotations\CachedReader;
7+
use Doctrine\Common\Annotations\Reader;
8+
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
9+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
10+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
11+
use Symfony\Component\Cache\Adapter\NullAdapter;
12+
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
13+
use Symfony\Component\Cache\DoctrineProvider;
14+
use Symfony\Component\Filesystem\Filesystem;
15+
16+
class AnnotationsCacheWarmerTest extends TestCase
17+
{
18+
private $cacheDir;
19+
20+
protected function setUp()
21+
{
22+
$this->cacheDir = sys_get_temp_dir().'/'.uniqid();
23+
$fs = new Filesystem();
24+
$fs->mkdir($this->cacheDir);
25+
parent::setUp();
26+
}
27+
28+
protected function tearDown()
29+
{
30+
$fs = new Filesystem();
31+
$fs->remove($this->cacheDir);
32+
parent::tearDown();
33+
}
34+
35+
public function testAnnotationsCacheWarmerWithDebugDisabled()
36+
{
37+
file_put_contents($this->cacheDir.'/annotations.map', sprintf('<?php return %s;', var_export(array(__CLASS__), true)));
38+
$cacheFile = tempnam($this->cacheDir, __FUNCTION__);
39+
$reader = new AnnotationReader();
40+
$fallbackPool = new ArrayAdapter();
41+
$warmer = new AnnotationsCacheWarmer(
42+
$reader,
43+
$cacheFile,
44+
$fallbackPool,
45+
null
46+
);
47+
$warmer->warmUp($this->cacheDir);
48+
$this->assertFileExists($cacheFile);
49+
50+
// Assert cache is valid
51+
$reader = new CachedReader(
52+
$this->getReadOnlyReader(),
53+
new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter()))
54+
);
55+
$refClass = new \ReflectionClass($this);
56+
$reader->getClassAnnotations($refClass);
57+
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));
58+
$reader->getPropertyAnnotations($refClass->getProperty('cacheDir'));
59+
}
60+
61+
public function testAnnotationsCacheWarmerWithDebugEnabled()
62+
{
63+
file_put_contents($this->cacheDir.'/annotations.map', sprintf('<?php return %s;', var_export(array(__CLASS__), true)));
64+
$cacheFile = tempnam($this->cacheDir, __FUNCTION__);
65+
$reader = new AnnotationReader();
66+
$fallbackPool = new ArrayAdapter();
67+
$warmer = new AnnotationsCacheWarmer(
68+
$reader,
69+
$cacheFile,
70+
$fallbackPool,
71+
null,
72+
true
73+
);
74+
$warmer->warmUp($this->cacheDir);
75+
$this->assertFileExists($cacheFile);
76+
// Assert cache is valid
77+
$reader = new CachedReader(
78+
$this->getReadOnlyReader(),
79+
new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter())),
80+
true
81+
);
82+
$refClass = new \ReflectionClass($this);
83+
$reader->getClassAnnotations($refClass);
84+
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));
85+
$reader->getPropertyAnnotations($refClass->getProperty('cacheDir'));
86+
}
87+
88+
/**
89+
* @return \PHPUnit_Framework_MockObject_MockObject|Reader
90+
*/
91+
private function getReadOnlyReader()
92+
{
93+
$readerMock = $this->getMockBuilder('Doctrine\Common\Annotations\Reader')->getMock();
94+
$readerMock->expects($this->exactly(0))->method('getClassAnnotations');
95+
$readerMock->expects($this->exactly(0))->method('getClassAnnotation');
96+
$readerMock->expects($this->exactly(0))->method('getMethodAnnotations');
97+
$readerMock->expects($this->exactly(0))->method('getMethodAnnotation');
98+
$readerMock->expects($this->exactly(0))->method('getPropertyAnnotations');
99+
$readerMock->expects($this->exactly(0))->method('getPropertyAnnotation');
100+
101+
return $readerMock;
102+
}
103+
}

0 commit comments

Comments
 (0)
0