Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[ExpressionLanguage] Making cache PSR6 compliant#19741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
*/ | ||
private $adapter; | ||
public function __construct(AdapterInterface $adapter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should be type hinted againstPsr\Cache\CacheItemInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You mean Psr\Cache\CacheItemPoolInterface, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
yes!
nicolas-grekas commentedAug 26, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
New features should be submitted on master (but no need to close this PR: you can either rebase then change the base branch yourself in the github UI, or we can do it while merging). Btw, shouldn't we deprecate |
/** | ||
* @author Alexandre GESLIN <alexandre@gesl.in> | ||
*/ | ||
class AdapterParserCache implements ParserCacheInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this is not an AdapterParserCache. It is a PSR6ParserCache
tests are missing btw |
@nicolas-grekas you're right we should deprecate But what does this involve in EL component ? I can add This is my first PR tentative, so be indulgent ^^ hope my questions are not too boring |
yes
yes! by removing the type hint (not replacing it with CacheItemPoolInterface), then doing dynamic checks in the constructor and triggering a deprecation when required |
ReDnAxE commentedAug 28, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for your help@nicolas-grekas. I have a few other questions :
|
{ | ||
$this->cache = $cache ?: new ArrayParserCache(); | ||
if (null !== $cache && false === is_a($cache, CacheItemPoolInterface::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should be:
if (null !==$cache && !$cacheinstanceof CacheItemPoolInterface) {
Since 5.0.0 :P
This function became deprecated in favour of the instanceof operator. Calling this function will result in an E_STRICT warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
even shorter:if ($cache instanceof ParserCacheInterface) {
@trigger_error(sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of 3.2 and will be removed in 4.0. Pass an instance of %s instead.', ParserCacheInterface::class, self::class, CacheItemPoolInterface::class), E_USER_DEPRECATED); | ||
$cache = new ParserCacheAdapter($cache); | ||
} elseif (!$cache instanceof CacheItemPoolInterface) { | ||
throw new \InvalidArgumentException(sprintf('Cache argument has to implements %s.', CacheItemPoolInterface::class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
implement
public function getItem($key) | ||
{ | ||
$value = $this->pool->fetch($key); | ||
$f = $this->createCacheItem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes, not working with$this->createCacheItem($key, $value, $isHit);
picked up herehttps://github.com/symfony/symfony/blob/master/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php#L75
👍 |
Could someone explain me why in the last build Here is the exception thrown all the time : |
@ReDnAxE Should be fixed now |
ReDnAxE commentedSep 30, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I thinkwe should try harder following@stof's advice. The tests don't decide. |
@nicolas-grekas I agree... This is why I prefer to mention him |
Can you add the trigger again so that we can see what's failing in the tests? |
ReDnAxE commentedSep 30, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas Why not ! I re-push the With the same |
Not related I guess |
ReDnAxE commentedSep 30, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I rebased my branch to533c11c (master) |
ReDnAxE commentedSep 30, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I rebased on418944b |
ReDnAxE commentedSep 30, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas it works better when rebasing on master's clean commit ;) |
Please also add the deprecation in the upgrade files. |
nicolas-grekas commentedOct 5, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
why that? that could still happen for 3.2 , who knows :) |
/** | ||
* @author Alexandre GESLIN <alexandre@gesl.in> | ||
* | ||
* @internal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You add a comment to indicate that this class should be removed in 4.0.
Indeed, I'd like to include that in 3.2 if possible. |
👍 from me after the remaining comments have been addressed |
ReDnAxE commentedOct 6, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thank's ! I'll make thoses changes this afternoon :) I learned that features was freezed for 3.2. This is why I changed to 3.3 |
The changes are done. |
ping@nicolas-grekas ;) |
Thank you@ReDnAxE. |
…andre GESLIN)This PR was merged into the 3.2-dev branch.Discussion----------[ExpressionLanguage] Making cache PSR6 compliant| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets | N/A| License | MIT| Doc PR | [#7064](symfony/symfony-docs#7064)Adding Cache component compatible ParserCache in ExpressionLanguage component.I hope you will find it useful :) I would like to make tests alsoCommits-------a7352ff [ExpressionLanguage] Making cache PSR6 compliant
This PR was merged into the master branch.Discussion----------Update caching.rstUpdating doc for this PR Making cache PSR6 compliant : [#19741](symfony/symfony#19741)Commits-------f03f2f3 Update caching.rst
Uh oh!
There was an error while loading.Please reload this page.
Adding Cache component compatible ParserCache in ExpressionLanguage component.
I hope you will find it useful :) I would like to make tests also