8000 Merge branch '4.3' into 4.4 · symfony/symfony@651de17 · GitHub
[go: up one dir, main page]

Skip to content

Commit 651de17

Browse files
Merge branch '4.3' into 4.4
* 4.3: [Cache] replace getNsSeparator by NS_SEPARATOR on AbstractTrait [Cache] fix versioning with SimpleCacheAdapter [Messenger] fix AMQP delay queue to be per exchange Fix expired lock not cleaned [HttpClient] throw DecodingExceptionInterface when toArray() fails because of content-type error [HttpFoundation] Fix SA/phpdoc JsonResponse [DI] Show the right class autowired when providing a non-existing class in constructor SimpleCacheAdapter fails to cache any item if a namespace is used validate composite constraints in all groups [Serializer] Handle true and false appropriately in CSV encoder [Messenger] improve logs [Messenger] fix delay delivery for non-fanout exchanges Parameterize Mailgun's region Fix binary operation `+`, `-` or `*` on string [VarDumper] fix dumping objects that implement __debugInfo() [HttpClient] Don't use CurlHttpClient on Windows when curl.cainfo is not set Add statement to fileLink to ignore href code when no fileLink. [Routing] fix absolute url generation when scheme is not known
2 parents 6ee3efa + 953ac3e commit 651de17

File tree

55 files changed

+607
-246
lines changed
  • VarDumper/Caster
  • Contracts/HttpClient
  • Some content is hidden

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

    55 files changed

    +607
    -246
    lines changed

    src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -557,8 +557,11 @@ private function formatControllerLink($controller, string $anchorText): string
    557557
    }
    558558

    559559
    $fileLink = $this->fileLinkFormatter->format($r->getFileName(), $r->getStartLine());
    560+
    if ($fileLink) {
    561+
    return sprintf('<href=%s>%s</>', $fileLink, $anchorText);
    562+
    }
    560563

    561-
    return sprintf('<href=%s>%s</>', $fileLink, $anchorText);
    564+
    return $anchorText;
    562565
    }
    563566

    564567
    private function formatCallable($callable): string

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

    Lines changed: 6 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -26,6 +26,11 @@
    2626
    */
    2727
    abstract class AbstractAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface
    2828
    {
    29+
    /**
    30+
    * @internal
    31+
    */
    32+
    protected const NS_SEPARATOR = ':';
    33+
    2934
    use AbstractAdapterTrait;
    3035
    use ContractsTrait;
    3136

    @@ -34,7 +39,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
    3439

    3540
    protected function __construct(string $namespace = '', int $defaultLifetime = 0)
    3641
    {
    37-
    $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
    42+
    $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).static::NS_SEPARATOR;
    3843
    if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
    3944
    throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
    4045
    }

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

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -23,6 +23,11 @@
    2323
    */
    2424
    class Psr16Adapter extends AbstractAdapter implements PruneableInterface, ResettableInterface
    2525
    {
    26+
    /**
    27+
    * @internal
    28+
    */
    29+
    protected const NS_SEPARATOR = '_';
    30+
    2631
    use ProxyTrait;
    2732

    2833
    private $miss;

    src/Symfony/Component/Cache/Simple/AbstractCache.php

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -27,6 +27,11 @@
    2727
    */
    2828
    abstract class AbstractCache implements Psr16CacheInterface, LoggerAwareInterface, ResettableInterface
    2929
    {
    30+
    /**
    31+
    * @internal
    32+
    */
    33+
    protected const NS_SEPARATOR = ':';
    34+
    3035
    use AbstractTrait {
    3136
    deleteItems as private;
    3237
    AbstractTrait::deleteItem as delete;

    src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -56,7 +56,7 @@ public function testLongKeyVersioning()
    5656
    $reflectionProperty->setValue($cache, true);
    5757

    5858
    // Versioning enabled
    59-
    $this->assertEquals('--------------------------:1/------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
    59+
    $this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
    6060
    $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
    6161
    $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
    6262
    $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));

    src/Symfony/Component/Cache/Tests/Adapter/Psr16AdapterTest.php

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

    1212
    namespace Symfony\Component\Cache\Tests\Adapter;
    1313

    14+
    use Symfony\Component\Cache\Adapter\ArrayAdapter;
    1415
    use Symfony\Component\Cache\Adapter\FilesystemAdapter;
    1516
    use Symfony\Component\Cache\Adapter\Psr16Adapter;
    1617
    use Symfony\Component\Cache\Psr16Cache;
    @@ -28,4 +29,14 @@ public function createCachePool($defaultLifetime = 0)
    2829
    {
    2930
    return new Psr16Adapter(new Psr16Cache(new FilesystemAdapter()), '', $defaultLifetime);
    3031
    }
    32+
    33+
    public function testValidCacheKeyWithNamespace()
    34+
    {
    35+
    $cache = new Psr16Adapter(new Psr16Cache(new ArrayAdapter()), 'some_namespace', 0);
    36+
    $item = $cache->getItem('my_key');
    37+
    $item->set('someValue');
    38+
    $cache->save($item);
    39+
    40+
    $this->assertTrue($cache->getItem('my_key')->isHit(), 'Stored item is successfully retrieved.');
    41+
    }
    3142
    }

    src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php

    Lines changed: 11 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,6 +13,7 @@
    1313

    1414
    use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
    1515
    use Symfony\Component\Cache\Simple\FilesystemCache;
    16+
    use Symfony\Component\Cache\Simple\ArrayCache;
    1617

    1718
    /**
    1819
    * @group time-sensitive
    @@ -28,4 +29,14 @@ public function createCachePool($defaultLifetime = 0)
    2829
    {
    2930
    return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime);
    3031
    }
    32+
    33+
    public function testValidCacheKeyWithNamespace()
    34+
    {
    35+
    $cache = new SimpleCacheAdapter(new ArrayCache(), 'some_namespace', 0);
    36+
    $item = $cache->getItem('my_key');
    37+
    $item->set('someValue');
    38+
    $cache->save($item);
    39+
    40+
    $this->assertTrue($cache->getItem('my_key')->isHit(), 'Stored item is successfully retrieved.');
    41+
    }
    3142
    }

    src/Symfony/Component/Cache/Traits/AbstractTrait.php

    Lines changed: 8 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -107,9 +107,9 @@ public function clear()
    107107
    {
    108108
    $this->deferred = [];
    109109
    if ($cleared = $this->versioningIsEnabled) {
    110-
    $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5);
    110+
    $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), static::NS_SEPARATOR, 5);
    111111
    try {
    112-
    $cleared = $this->doSave(['/'.$this->namespace => $namespaceVersion], 0);
    112+
    $cleared = $this->doSave([static::NS_SEPARATOR.$this->namespace => $namespaceVersion], 0);
    113113
    } catch (\Exception $e) {
    114114
    $cleared = false;
    115115
    }
    @@ -243,14 +243,14 @@ private function getId($key)
    243243
    {
    244244
    if ($this->versioningIsEnabled && '' === $this->namespaceVersion) {
    245245
    $this->ids = [];
    246-
    $this->namespaceVersion = '1/';
    246+
    $this->namespaceVersion = '1'.static::NS_SEPARATOR;
    247247
    try {
    248-
    foreach ($this->doFetch(['/'.$this->namespace]) as $v) {
    248+
    foreach ($this->doFetch([static::NS_SEPARATOR.$this->namespace]) as $v) {
    249249
    $this->namespaceVersion = $v;
    250250
    }
    251-
    if ('1:' === $this->namespaceVersion) {
    252-
    $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5);
    253-
    $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0);
    251+
    if ('1'.static::NS_SEPARATOR === $this->namespaceVersion) {
    252+
    $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), static::NS_SEPARATOR, 5);
    253+
    $this->doSave([static::NS_SEPARATOR.$this->namespace => $this->namespaceVersion], 0);
    254254
    }
    255255
    } catch (\Exception $e) {
    256256
    }
    @@ -267,7 +267,7 @@ private function getId($key)
    267267
    }
    268268
    if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
    269269
    // Use MD5 to favor speed over security, which is not an issue here
    270-
    $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), ':', -(\strlen($this->namespaceVersion) + 2));
    270+
    $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2));
    271271
    $id = $this->namespace.$this->namespaceVersion.$id;
    272272
    }
    273273

    src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

    Lines changed: 5 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -379,13 +379,14 @@ private function createTypeNotFoundMessageCallback(TypedReference $reference, $l
    379379
    $container->setAliases($this->container->getAliases());
    380380
    $container->setDefinitions($this->container->getDefinitions());
    381381
    $container->setResourceTracking(false);
    382+
    $currentId = $this->currentId;
    382383

    383-
    return function () use ($container, $reference, $label) {
    384-
    return $this->createTypeNotFoundMessage($container, $reference, $label);
    384+
    return function () use ($container, $reference, $label, $currentId) {
    385+
    return $this->createTypeNotFoundMessage($container, $reference, $label, $currentId);
    385386
    };
    386387
    }
    387388

    388-
    private function createTypeNotFoundMessage(ContainerBuilder $container, TypedReference $reference, $label)
    389+
    private function createTypeNotFoundMessage(ContainerBuilder $container, TypedReference $reference, $label, string $currentId)
    389390
    {
    390391
    if (!$r = $container->getReflectionClass($type = $reference->getType(), false)) {
    391392
    // either $type does not exist or a parent class does not exist
    @@ -409,7 +410,7 @@ private function createTypeNotFoundMessage(ContainerBuilder $container, TypedRef
    409410
    }
    410411
    }
    411412

    412-
    $message = sprintf('Cannot autowire service "%s": %s %s', $this->currentId, $label, $message);
    413+
    $message = sprintf('Cannot autowire service "%s": %s %s', $currentId, $label, $message);
    413414

    414415
    if (null !== $this->lastFailure) {
    415416
    $message = $this->lastFailure."\n".$message;

    src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

    Lines changed: 16 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -50,6 +50,22 @@ public function testProcess()
    5050
    $this->assertEquals(Foo::class, (string) $container->getDefinition('bar')->getArgument(0));
    5151
    }
    5252

    53+
    /**
    54+
    * @expectedException \Symfony\Component\DependencyInjection\Exception\AutowiringFailedException
    55+
    * @expectedExceptionMessage Cannot autowire service "Symfony\Component\DependencyInjection\Tests\CompilerEslaAction": argument "$notExisting" of method "Symfony\Component\DependencyInjection\Tests\Compiler\ElsaAction::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotExisting" but this class was not found.
    56+
    */
    57+
    public function testProcessNotExistingActionParam()
    58+
    {
    59+
    $container = new ContainerBuilder();
    60+
    61+
    $container->register(Foo::class);
    62+
    $barDefinition = $container->register(__NAMESPACE__.'EslaAction', __NAMESPACE__.'\ElsaAction');
    63+
    $barDefinition->setAutowired(true);
    64+
    65+
    (new ResolveClassPass())->process($container);
    66+
    (new AutowirePass())->process($container);
    67+
    }
    68+
    5369
    public function testProcessVariadic()
    5470
    {
    5571
    $container = new ContainerBuilder();

    0 commit comments

    Comments
     (0)
    0