Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5006be6

Browse files
[Cache] deprecate all PSR-16 adapters, provide Psr16Cache instead
1 parentcafbdb7 commit5006be6

File tree

53 files changed

+788
-385
lines changed

Some content is hidden

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

53 files changed

+788
-385
lines changed

‎UPGRADE-4.3.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ BrowserKit
88
* Deprecated`Response::buildHeader()`
99
* Deprecated`Response::getStatus()`, use`Response::getStatusCode()` instead
1010

11+
Cache
12+
-----
13+
14+
* The`psr/simple-cache` dependency has been removed - run`composer require psr/simple-cache` if you need it.
15+
* Deprecated all PSR-16 adapters, use`Psr16Cache` or`Symfony\Contracts\Cache\CacheInterface` implementations instead.
16+
* Deprecated`SimpleCacheAdapter`, use `Psr16Adapter instead.
17+
1118
Config
1219
------
1320

@@ -18,6 +25,7 @@ FrameworkBundle
1825

1926
* Not passing the project directory to the constructor of the`AssetsInstallCommand` is deprecated. This argument will
2027
be mandatory in 5.0.
28+
* Deprecated the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
2129

2230
HttpFoundation
2331
--------------

‎UPGRADE-5.0.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Cache
1313
-----
1414

1515
* Removed`CacheItem::getPreviousTags()`, use`CacheItem::getMetadata()` instead.
16+
* Removed all PSR-16 adapters, use`Psr16Cache` or`Symfony\Contracts\Cache\CacheInterface` implementations instead.
17+
* Removed`SimpleCacheAdapter`, use `Psr16Adapter instead.
1618

1719
Config
1820
------
@@ -163,6 +165,7 @@ FrameworkBundle
163165
* The `Templating\Helper\TranslatorHelper::transChoice()` method has been removed, use the `trans()` one instead with a `%count%` parameter.
164166
* Removed support for legacy translations directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`, use `translations/` instead.
165167
* Support for the legacy directory structure in `translation:update` and `debug:translation` commands has been removed.
168+
* Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
166169

167170
HttpFoundation
168171
--------------

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
be mandatory in 5.0.
99
* Added`ControllerTrait::isFormValid()`
1010
* Added an`help_html` form option to display the`help` text as HTML
11+
* Deprecated the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead
1112

1213
*[BC Break] When using Messenger, the default transport changed from
1314
using Symfony's serializer service to use`PhpSerializer`, which uses

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<tagname="cache.pool"clearer="cache.app_clearer"reset="reset" />
1212
</service>
1313

14-
<serviceid="cache.app.simple"class="Symfony\Component\Cache\Simple\Psr6Cache">
14+
<serviceid="cache.app.simple"class="Symfony\Component\Cache\Psr16Cache">
15+
<deprecated>The "Psr\SimpleCache\CacheInterface" / "%service_id%" service is deprecated since Symfony 4.3. Use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.</deprecated>
1516
<argumenttype="service"id="cache.app" />
1617
</service>
1718

‎src/Symfony/Bundle/FrameworkBundle/composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php":"^7.1.3",
2020
"ext-xml":"*",
21-
"symfony/cache":"~4.2",
21+
"symfony/cache":"~4.3",
2222
"symfony/config":"~4.2",
2323
"symfony/contracts":"^1.0.2",
2424
"symfony/dependency-injection":"^4.2",
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Cache\Adapter;
13+
14+
usePsr\SimpleCache\CacheInterface;
15+
useSymfony\Component\Cache\PruneableInterface;
16+
useSymfony\Component\Cache\ResettableInterface;
17+
useSymfony\Component\Cache\Traits\ProxyTrait;
18+
19+
/**
20+
* Turns a PSR-16 cache into a PSR-6 one.
21+
*
22+
* @author Nicolas Grekas <p@tchwork.com>
23+
*/
24+
class Psr16Adapterextends AbstractAdapterimplements PruneableInterface, ResettableInterface
25+
{
26+
use ProxyTrait;
27+
28+
private$miss;
29+
30+
publicfunction__construct(CacheInterface$pool,string$namespace ='',int$defaultLifetime =0)
31+
{
32+
parent::__construct($namespace,$defaultLifetime);
33+
34+
$this->pool =$pool;
35+
$this->miss =new \stdClass();
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
protectedfunctiondoFetch(array$ids)
42+
{
43+
foreach ($this->pool->getMultiple($ids,$this->miss)as$key =>$value) {
44+
if ($this->miss !==$value) {
45+
yield$key =>$value;
46+
}
47+
}
48+
}
49+
50+
/**
51+
* {@inheritdoc}
52+
*/
53+
protectedfunctiondoHave($id)
54+
{
55+
return$this->pool->has($id);
56+
}
57+
58+
/**
59+
* {@inheritdoc}
60+
*/
61+
protectedfunctiondoClear($namespace)
62+
{
63+
return$this->pool->clear();
64+
}
65+
66+
/**
67+
* {@inheritdoc}
68+
*/
69+
protectedfunctiondoDelete(array$ids)
70+
{
71+
return$this->pool->deleteMultiple($ids);
72+
}
73+
74+
/**
75+
* {@inheritdoc}
76+
*/
77+
protectedfunctiondoSave(array$values,$lifetime)
78+
{
79+
return$this->pool->setMultiple($values,0 ===$lifetime ?null :$lifetime);
80+
}
81+
}

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

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,69 +11,11 @@
1111

1212
namespaceSymfony\Component\Cache\Adapter;
1313

14-
usePsr\SimpleCache\CacheInterface;
15-
useSymfony\Component\Cache\PruneableInterface;
16-
useSymfony\Component\Cache\ResettableInterface;
17-
useSymfony\Component\Cache\Traits\ProxyTrait;
14+
@trigger_error(sprintf('The "%s" class is @deprecated since Symfony 4.3, use "Psr16Adapter" instead.', SimpleCacheAdapter::class),E_USER_DEPRECATED);
1815

1916
/**
20-
* @author Nicolas Grekas <p@tchwork.com>
17+
* @deprecated since Symfony 4.3, use Psr16Adapter instead.
2118
*/
22-
class SimpleCacheAdapterextendsAbstractAdapterimplements PruneableInterface, ResettableInterface
19+
class SimpleCacheAdapterextendsPsr16Adapter
2320
{
24-
use ProxyTrait;
25-
26-
private$miss;
27-
28-
publicfunction__construct(CacheInterface$pool,string$namespace ='',int$defaultLifetime =0)
29-
{
30-
parent::__construct($namespace,$defaultLifetime);
31-
32-
$this->pool =$pool;
33-
$this->miss =new \stdClass();
34-
}
35-
36-
/**
37-
* {@inheritdoc}
38-
*/
39-
protectedfunctiondoFetch(array$ids)
40-
{
41-
foreach ($this->pool->getMultiple($ids,$this->miss)as$key =>$value) {
42-
if ($this->miss !==$value) {
43-
yield$key =>$value;
44-
}
45-
}
46-
}
47-
48-
/**
49-
* {@inheritdoc}
50-
*/
51-
protectedfunctiondoHave($id)
52-
{
53-
return$this->pool->has($id);
54-
}
55-
56-
/**
57-
* {@inheritdoc}
58-
*/
59-
protectedfunctiondoClear($namespace)
60-
{
61-
return$this->pool->clear();
62-
}
63-
64-
/**
65-
* {@inheritdoc}
66-
*/
67-
protectedfunctiondoDelete(array$ids)
68-
{
69-
return$this->pool->deleteMultiple($ids);
70-
}
71-
72-
/**
73-
* {@inheritdoc}
74-
*/
75-
protectedfunctiondoSave(array$values,$lifetime)
76-
{
77-
return$this->pool->setMultiple($values,0 ===$lifetime ?null :$lifetime);
78-
}
7921
}

‎src/Symfony/Component/Cache/CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
4.3.0
5+
-----
6+
7+
* removed`psr/simple-cache` dependency, run`composer require psr/simple-cache` if you need it
8+
* deprecated all PSR-16 adapters, use`Psr16Cache` or`Symfony\Contracts\Cache\CacheInterface` implementations instead
9+
* deprecated`SimpleCacheAdapter`, use`Psr16Adapter` instead
10+
411
4.2.0
512
-----
613

‎src/Symfony/Component/Cache/Exception/CacheException.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
usePsr\Cache\CacheExceptionasPsr6CacheInterface;
1515
usePsr\SimpleCache\CacheExceptionasSimpleCacheInterface;
1616

17-
class CacheExceptionextends \Exceptionimplements Psr6CacheInterface, SimpleCacheInterface
18-
{
17+
if (interface_exists(SimpleCacheInterface::class)) {
18+
class CacheExceptionextends \Exceptionimplements Psr6CacheInterface, SimpleCacheInterface
19+
{
20+
}
21+
}else {
22+
class CacheExceptionextends \Exceptionimplements Psr6CacheInterface
23+
{
24+
}
1925
}

‎src/Symfony/Component/Cache/Exception/InvalidArgumentException.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
usePsr\Cache\InvalidArgumentExceptionasPsr6CacheInterface;
1515
usePsr\SimpleCache\InvalidArgumentExceptionasSimpleCacheInterface;
1616

17-
class InvalidArgumentExceptionextends \InvalidArgumentExceptionimplements Psr6CacheInterface, SimpleCacheInterface
18-
{
17+
if (interface_exists(SimpleCacheInterface::class)) {
18+
class InvalidArgumentExceptionextends \InvalidArgumentExceptionimplements Psr6CacheInterface, SimpleCacheInterface
19+
{
20+
}
21+
}else {
22+
class InvalidArgumentExceptionextends \InvalidArgumentExceptionimplements Psr6CacheInterface
23+
{
24+
}
1925
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp