Skip to content

Commit 3640585

Browse files
committed
Merge branch '3.4'
* 3.4: use the parseFile() method of the YAML parser [Yaml] support parsing files Adding Definition::addError() and a compiler pass to throw errors as exceptions [DI] Add AutowireRequiredMethodsPass to fix bindings for `@required` methods [Cache] Add ResettableInterface to allow resetting any pool's local state [DI][DX] Throw exception on some ContainerBuilder methods used from extensions added missing @author tag for new class allow forms without translations and validator [VarDumper] Make `dump()` a little bit more easier to use [Form] Add ambiguous & exception debug:form tests Reset the authentication token between requests. [Serializer] Getter for extra attributes in ExtraAttributesException [DI] Dont use JSON_BIGINT_AS_STRING # Conflicts: # src/Symfony/Component/Routing/composer.json # src/Symfony/Component/Translation/composer.json # src/Symfony/Component/Yaml/Inline.php # src/Symfony/Component/Yaml/Tests/ParserTest.php # src/Symfony/Component/Yaml/Yaml.php
2 parents 2a07f4b + 55aa662 commit 3640585

File tree

76 files changed

+1430
-575
lines changed

Some content is hidden

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

76 files changed

+1430
-575
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function process(ContainerBuilder $container)
4343
'provider',
4444
'namespace',
4545
'default_lifetime',
46+
'reset',
4647
);
4748
foreach ($container->findTaggedServiceIds('cache.pool') as $id => $tags) {
4849
$adapter = $pool = $container->getDefinition($id);
@@ -73,13 +74,19 @@ public function process(ContainerBuilder $container)
7374
}
7475
$i = 0;
7576
foreach ($attributes as $attr) {
76-
if (isset($tags[0][$attr]) && ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass())) {
77+
if (!isset($tags[0][$attr])) {
78+
// no-op
79+
} elseif ('reset' === $attr) {
80+
if ($tags[0][$attr]) {
81+
$pool->addTag('kernel.reset', array('method' => $tags[0][$attr]));
82+
}
83+
} elseif ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass()) {
7784
$pool->replaceArgument($i++, $tags[0][$attr]);
7885
}
7986
unset($tags[0][$attr]);
8087
}
8188
if (!empty($tags[0])) {
82-
throw new InvalidArgumentException(sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "clearer", "provider", "namespace" and "default_lifetime", found "%s".', $id, implode('", "', array_keys($tags[0]))));
89+
throw new InvalidArgumentException(sprintf('Invalid "cache.pool" tag for service "%s": accepted attributes are "clearer", "provider", "namespace", "default_lifetime" and "reset", found "%s".', $id, implode('", "', array_keys($tags[0]))));
8390
}
8491

8592
if (null !== $clearer) {

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
2626
use Symfony\Component\Cache\Adapter\AdapterInterface;
2727
use Symfony\Component\Cache\Adapter\ArrayAdapter;
28+
use Symfony\Component\Cache\ResettableInterface;
2829
use Symfony\Component\Config\FileLocator;
2930
use Symfony\Component\Config\Loader\LoaderInterface;
3031
use Symfony\Component\Config\Resource\DirectoryResource;
@@ -72,6 +73,7 @@
7273
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
7374
use Symfony\Component\Stopwatch\Stopwatch;
7475
use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
76+
use Symfony\Component\Translation\Translator;
7577
use Symfony\Component\Validator\ConstraintValidatorInterface;
7678
use Symfony\Component\Validator\ObjectInitializerInterface;
7779
use Symfony\Component\WebLink\HttpHeaderSerializer;
@@ -146,15 +148,13 @@ public function load(array $configs, ContainerBuilder $container)
146148
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed.');
147149
}
148150

149-
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['form'])) {
150-
throw new LogicException('Form support cannot be enabled as the Translation component is not installed.');
151-
}
152-
153151
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['validation'])) {
154152
throw new LogicException('Validation support cannot be enabled as the Translation component is not installed.');
155153
}
156154

157-
$loader->load('identity_translator.xml');
155+
if (class_exists(Translator::class)) {
156+
$loader->load('identity_translator.xml');
157+
}
158158
}
159159

160160
if (isset($config['secret'])) {
@@ -200,7 +200,10 @@ public function load(array $configs, ContainerBuilder $container)
200200
$config['validation']['enabled'] = true;
201201

202202
if (!class_exists('Symfony\Component\Validator\Validation')) {
203-
throw new LogicException('The Validator component is required to use the Form component.');
203+
$container->setParameter('validator.translation_domain', 'validators');
204+
205+
$container->removeDefinition('form.type_extension.form.validator');
206+
$container->removeDefinition('form.type_guesser.validator');
204207
}
205208
} else {
206209
$container->removeDefinition('Symfony\Component\Form\Command\DebugCommand');
@@ -287,6 +290,8 @@ public function load(array $configs, ContainerBuilder $container)
287290
->addTag('kernel.cache_warmer');
288291
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
289292
->addTag('kernel.event_subscriber');
293+
$container->registerForAutoconfiguration(ResettableInterface::class)
294+
->addTag('kernel.reset', array('method' => 'reset'));
290295
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
291296
->addTag('property_info.list_extractor');
292297
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
@@ -342,6 +347,10 @@ private function registerFormConfiguration($config, ContainerBuilder $container,
342347
} else {
343348
$container->setParameter('form.type_extension.csrf.enabled', false);
344349
}
350+
351+
if (!class_exists(Translator::class)) {
352+
$container->removeDefinition('form.type_extension.upload.validator');
353+
}
345354
}
346355

347356
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<defaults public="false" />
99

1010
<service id="cache.app" parent="cache.adapter.filesystem" public="true">
11-
<tag name="cache.pool" clearer="cache.app_clearer" />
11+
<tag name="cache.pool" clearer="cache.app_clearer" reset="reset" />
1212
</service>
1313

1414
<service id="cache.system" parent="cache.adapter.system" public="true">
@@ -90,7 +90,7 @@
9090
</service>
9191

9292
<service id="cache.adapter.memcached" class="Symfony\Component\Cache\Adapter\MemcachedAdapter" abstract="true">
93-
<tag name="cache.pool" provider="cache.default_memcached_provider" clearer="cache.default_clearer" />
93+
<tag name="cache.pool" provider="cache.default_memcached_provider" clearer="cache.default_clearer" reset="reset" />
9494
<tag name="monolog.logger" channel="cache" />
9595
<argument /> <!-- Memcached connection service -->
9696
<argument /> <!-- namespace -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<argument type="service" id="security.csrf.token_manager" />
1313
<argument>%form.type_extension.csrf.enabled%</argument>
1414
<argument>%form.type_extension.csrf.field_name%</argument>
15-
<argument type="service" id="translator" />
15+
<argument type="service" id="translator" on-invalid="null" />
1616
<argument>%validator.translation_domain%</argument>
1717
<argument type="service" id="form.server_params" />
1818
</service>

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
</service>
2222
<service id="Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface" alias="security.authorization_checker" />
2323

24-
<service id="security.token_storage" class="Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage" public="true" />
24+
<service id="security.token_storage" class="Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage" public="true">
25+
<tag name="kernel.reset" method="setToken" />
26+
</service>
2527
<service id="Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface" alias="security.token_storage" />
2628

2729
<service id="security.user_value_resolver" class="Symfony\Bundle\SecurityBundle\SecurityUserValueResolver">

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
use Psr\Log\NullLogger;
1818
use Symfony\Component\Cache\CacheItem;
1919
use Symfony\Component\Cache\Exception\InvalidArgumentException;
20+
use Symfony\Component\Cache\ResettableInterface;
2021
use Symfony\Component\Cache\Traits\AbstractTrait;
2122

2223
/**
2324
* @author Nicolas Grekas <[email protected]>
2425
*/
25-
abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
26+
abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface, ResettableInterface
2627
{
2728
use AbstractTrait;
2829

src/Symfony/Component/Cache/Adapter/ArrayAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
use Psr\Cache\CacheItemInterface;
1515
use Psr\Log\LoggerAwareInterface;
1616
use Symfony\Component\Cache\CacheItem;
17+
use Symfony\Component\Cache\ResettableInterface;
1718
use Symfony\Component\Cache\Traits\ArrayTrait;
1819

1920
/**
2021
* @author Nicolas Grekas <[email protected]>
2122
*/
22-
class ArrayAdapter implements AdapterInterface, LoggerAwareInterface
23+
class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, ResettableInterface
2324
{
2425
use ArrayTrait;
2526

src/Symfony/Component/Cache/Adapter/ChainAdapter.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Cache\CacheItem;
1717
use Symfony\Component\Cache\Exception\InvalidArgumentException;
1818
use Symfony\Component\Cache\PruneableInterface;
19+
use Symfony\Component\Cache\ResettableInterface;
1920

2021
/**
2122
* Chains several adapters together.
@@ -25,7 +26,7 @@
2526
*
2627
* @author Kévin Dunglas <[email protected]>
2728
*/
28-
class ChainAdapter implements AdapterInterface, PruneableInterface
29+
class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableInterface
2930
{
3031
private $adapters = array();
3132
private $adapterCount;
@@ -248,4 +249,16 @@ public function prune()
248249

249250
return $pruned;
250251
}
252+
253+
/**
254+
* {@inheritdoc}
255+
*/
256+
public function reset()
257+
{
258+
foreach ($this->adapters as $adapter) {
259+
if ($adapter instanceof ResettableInterface) {
260+
$adapter->reset();
261+
}
262+
}
263+
}
251264
}

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Psr\Cache\CacheItemPoolInterface;
1616
use Symfony\Component\Cache\CacheItem;
1717
use Symfony\Component\Cache\Exception\InvalidArgumentException;
18+
use Symfony\Component\Cache\PruneableInterface;
19+
use Symfony\Component\Cache\ResettableInterface;
1820
use Symfony\Component\Cache\Traits\PhpArrayTrait;
1921

2022
/**
@@ -24,7 +26,7 @@
2426
* @author Titouan Galopin <[email protected]>
2527
* @author Nicolas Grekas <[email protected]>
2628
*/
27-
class PhpArrayAdapter implements AdapterInterface
29+
class PhpArrayAdapter implements AdapterInterface, PruneableInterface, ResettableInterface
2830
{
2931
use PhpArrayTrait;
3032

@@ -37,7 +39,7 @@ class PhpArrayAdapter implements AdapterInterface
3739
public function __construct($file, AdapterInterface $fallbackPool)
3840
{
3941
$this->file = $file;
40-
$this->fallbackPool = $fallbackPool;
42+
$this->pool = $fallbackPool;
4143
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
4244
$this->createCacheItem = \Closure::bind(
4345
function ($key, $value, $isHit) {
@@ -87,7 +89,7 @@ public function getItem($key)
8789
$this->initialize();
8890
}
8991
if (!isset($this->values[$key])) {
90-
return $this->fallbackPool->getItem($key);
92+
return $this->pool->getItem($key);
9193
}
9294

9395
$value = $this->values[$key];
@@ -142,7 +144,7 @@ public function hasItem($key)
142144
$this->initialize();
143145
}
144146

145-
return isset($this->values[$key]) || $this->fallbackPool->hasItem($key);
147+
return isset($this->values[$key]) || $this->pool->hasItem($key);
146148
}
147149

148150
/**
@@ -157,7 +159,7 @@ public function deleteItem($key)
157159
$this->initialize();
158160
}
159161

160-
return !isset($this->values[$key]) && $this->fallbackPool->deleteItem($key);
162+
return !isset($this->values[$key]) && $this->pool->deleteItem($key);
161163
}
162164

163165
/**
@@ -184,7 +186,7 @@ public function deleteItems(array $keys)
184186
}
185187

186188
if ($fallbackKeys) {
187-
$deleted = $this->fallbackPool->deleteItems($fallbackKeys) && $deleted;
189+
$deleted = $this->pool->deleteItems($fallbackKeys) && $deleted;
188190
}
189191

190192
return $deleted;
@@ -199,7 +201,7 @@ public function save(CacheItemInterface $item)
199201
$this->initialize();
200202
}
201203

202-
return !isset($this->values[$item->getKey()]) && $this->fallbackPool->save($item);
204+
return !isset($this->values[$item->getKey()]) && $this->pool->save($item);
203205
}
204206

205207
/**
@@ -211,15 +213,15 @@ public function saveDeferred(CacheItemInterface $item)
211213
$this->initialize();
212214
}
213215

214-
return !isset($this->values[$item->getKey()]) && $this->fallbackPool->saveDeferred($item);
216+
return !isset($this->values[$item->getKey()]) && $this->pool->saveDeferred($item);
215217
}
216218

217219
/**
218220
* {@inheritdoc}
219221
*/
220222
public function commit()
221223
{
222-
return $this->fallbackPool->commit();
224+
return $this->pool->commit();
223225
}
224226

225227
/**
@@ -257,7 +259,7 @@ private function generateItems(array $keys)
257259
}
258260

259261
if ($fallbackKeys) {
260-
foreach ($this->fallbackPool->getItems($fallbackKeys) as $key => $item) {
262+
foreach ($this->pool->getItems($fallbackKeys) as $key => $item) {
261263
yield $key => $item;
262264
}
263265
}

src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
use Psr\Cache\CacheItemInterface;
1515
use Psr\Cache\CacheItemPoolInterface;
1616
use Symfony\Component\Cache\CacheItem;
17+
use Symfony\Component\Cache\PruneableInterface;
18+
use Symfony\Component\Cache\ResettableInterface;
19+
use Symfony\Component\Cache\Traits\ProxyTrait;
1720

1821
/**
1922
* @author Nicolas Grekas <[email protected]>
2023
*/
21-
class ProxyAdapter implements AdapterInterface
24+
class ProxyAdapter implements AdapterInterface, PruneableInterface, ResettableInterface
2225
{
23-
private $pool;
26+
use ProxyTrait;
27+
2428
private $namespace;
2529
private $namespaceLen;
2630
private $createCacheItem;

src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
namespace Symfony\Component\Cache\Adapter;
1313

1414
use Psr\SimpleCache\CacheInterface;
15+
use Symfony\Component\Cache\PruneableInterface;
16+
use Symfony\Component\Cache\ResettableInterface;
17+
use Symfony\Component\Cache\Traits\ProxyTrait;
1518

1619
/**
1720
* @author Nicolas Grekas <[email protected]>
1821
*/
19-
class SimpleCacheAdapter extends AbstractAdapter
22+
class SimpleCacheAdapter extends AbstractAdapter implements PruneableInterface, ResettableInterface
2023
{
21-
private $pool;
24+
use ProxyTrait;
25+
2226
private $miss;
2327

2428
public function __construct(CacheInterface $pool, $namespace = '', $defaultLifetime = 0)

0 commit comments

Comments
 (0)