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

[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

Merged
fabpot merged 1 commit intosymfony:masterfromReDnAxE:expression_language_cacheprovider
Oct 17, 2016
Merged

[ExpressionLanguage] Making cache PSR6 compliant#19741

fabpot merged 1 commit intosymfony:masterfromReDnAxE:expression_language_cacheprovider
Oct 17, 2016

Conversation

ReDnAxE
Copy link

@ReDnAxEReDnAxE commentedAug 26, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed ticketsN/A
LicenseMIT
Doc PR#7064

Adding Cache component compatible ParserCache in ExpressionLanguage component.
I hope you will find it useful :) I would like to make tests also

chalasr reacted with thumbs up emoji
*/
private $adapter;

public function __construct(AdapterInterface $adapter)

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

Copy link
Author

@ReDnAxEReDnAxEAug 26, 2016
edited
Loading

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 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yes!

ReDnAxE reacted with thumbs up emoji
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedAug 26, 2016
edited
Loading

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 deprecateParserCacheInterface in favor ofPsr\Cache\CacheItemPoolInterface?

ReDnAxE, jakzal, GuilhemN, sstok, Koc, and tjaari reacted with thumbs up emoji

/**
* @author Alexandre GESLIN <alexandre@gesl.in>
*/
class AdapterParserCache implements ParserCacheInterface
Copy link
Member

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

ReDnAxE, jakzal, and sstok reacted with thumbs up emoji
@stof
Copy link
Member

tests are missing btw

ReDnAxE and jakzal reacted with thumbs up emoji

@ReDnAxE
Copy link
Author

@nicolas-grekas you're right we should deprecateParserCacheInterface in favor ofPsr\Cache\CacheItemPoolInterface.

But what does this involve in EL component ?

I can add@deprecated tag onParserCacheInterface ? And then, how to stop use ofParserCacheInterface in ExpressionLanguage without creating BC break ? I mean, changing type hint on ExpressionLanguage::__construct is not conceivable, right ?

This is my first PR tentative, so be indulgent ^^ hope my questions are not too boring

@nicolas-grekas
Copy link
Member

add@deprecated tag on ParserCacheInterface

yes

changing type hint on ExpressionLanguage::__construct

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 reacted with thumbs up emoji

@ReDnAxEReDnAxE changed the title[ExpressionLanguage] adding cache component compatible ParserCache[ExpressionLanguage] Making cache PSR6 compliantAug 28, 2016
@ReDnAxE
Copy link
Author

ReDnAxE commentedAug 28, 2016
edited
Loading

Thanks for your help@nicolas-grekas.
I've made some changes in order to make cache PSR6 compliant, using adapter pattern.

I have a few other questions :

  • I useSymfony\Component\Cache\Adapter\ArrayAdapter by default inExpressionLanguage.php. Is it a bad thing to hard coupling with Cache component ? Perhaps it's better to use the existingArrayParserCache with the adapter.
  • With PSR6 specifications, some characters are forbidden in keys declarations. For now my sanitize method is not sufficient, but I don't know exactly how to assure unique keys with expressions. Replacing with a hash ?

{
$this->cache = $cache ?: new ArrayParserCache();
if (null !== $cache && false === is_a($cache, CacheItemPoolInterface::class)) {
Copy link
Contributor

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.

ReDnAxE reacted with thumbs up emoji

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) {

ReDnAxE reacted with thumbs up emoji
@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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

implement

ReDnAxE reacted with thumbs up emoji
public function getItem($key)
{
$value = $this->pool->fetch($key);
$f = $this->createCacheItem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this necessary?

Copy link
Author

@ReDnAxEReDnAxESep 30, 2016
edited
Loading

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

@xabbuh
Copy link
Member

👍

@ReDnAxE
Copy link
Author

Could someone explain me why in the last buildPHP:7 deph=high, I have 54 errors inSymfony\Bundle\SecurityBundle\Tests\Functional ?

Here is the exception thrown all the time :
Symfony\Component\DependencyInjection\Exception\LogicException: Asset support cannot be enabled as the Asset component is not installed.

@fabpot
Copy link
Member

@ReDnAxE Should be fixed now

@ReDnAxE
Copy link
Author

ReDnAxE commentedSep 30, 2016
edited
Loading

@stof with a@trigger_error inParserCache\ParserCacheInterface.php as you asked,PHP:7 deph=high was broken as explained above, I could not explain why.
@fabpot Builds are ok.

@nicolas-grekas
Copy link
Member

I thinkwe should try harder following@stof's advice. The tests don't decide.

@ReDnAxE
Copy link
Author

@nicolas-grekas I agree... This is why I prefer to mention him

@nicolas-grekas
Copy link
Member

Can you add the trigger again so that we can see what's failing in the tests?

@ReDnAxE
Copy link
Author

ReDnAxE commentedSep 30, 2016
edited
Loading

@nicolas-grekas Why not ! I re-push the@trigger_error.
I confess I do not understand. Now, it's no more the same errors : we have fails in PHP7 dep=high|low inTwigBundle Test Suite

With the sameSymfony\Component\DependencyInjection\Exception\LogicException exception type thrown as before

@nicolas-grekas
Copy link
Member

Not related I guess

@ReDnAxE
Copy link
Author

ReDnAxE commentedSep 30, 2016
edited
Loading

I rebased my branch to533c11c (master)
I will rebase one more time

@ReDnAxE
Copy link
Author

ReDnAxE commentedSep 30, 2016
edited
Loading

I rebased on418944b
same errors... uh no, worst, 1 error in appVeyor o_O :
Symfony\Component\HttpKernel\Tests\ClientTest::testGetScript RuntimeException: OUTPUT: ERROR OUTPUT:

@ReDnAxE
Copy link
Author

ReDnAxE commentedSep 30, 2016
edited
Loading

I know we are in 1 october, so it's probably too late ^^, but I saw master is not stable on the last418944b commit. Perhaps I would rebase on a older stable master commit ?

EDIT: I'm onc2d8356 now. Appveyor recovered..! good night ;)

@ReDnAxE
Copy link
Author

@nicolas-grekas it works better when rebasing on master's clean commit ;)
I changed deprecation notices versions from "3.2" to "3.3"

@xabbuh
Copy link
Member

Please also add the deprecation in the upgrade files.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedOct 5, 2016
edited
Loading

I changed deprecation notices versions from "3.2" to "3.3"

why that? that could still happen for 3.2 , who knows :)
also please add a note in the upgrade files as suggested by@xabbuh

/**
* @author Alexandre GESLIN <alexandre@gesl.in>
*
* @internal
Copy link
Member

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.

@fabpot
Copy link
Member

Indeed, I'd like to include that in 3.2 if possible.

@xabbuh
Copy link
Member

👍 from me after the remaining comments have been addressed

@ReDnAxE
Copy link
Author

ReDnAxE commentedOct 6, 2016
edited
Loading

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

@ReDnAxE
Copy link
Author

The changes are done.

@ReDnAxE
Copy link
Author

ping@nicolas-grekas ;)

@fabpot
Copy link
Member

Thank you@ReDnAxE.

@fabpotfabpot merged commita7352ff intosymfony:masterOct 17, 2016
fabpot added a commit that referenced this pull requestOct 17, 2016
…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
@fabpotfabpot mentioned this pull requestOct 27, 2016
wouterj added a commit to symfony/symfony-docs that referenced this pull requestNov 10, 2016
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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@xabbuhxabbuhxabbuh left review comments

@HeahDudeHeahDudeHeahDude left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

10 participants
@ReDnAxE@nicolas-grekas@stof@Koc@jeremyFreeAgent@xabbuh@fabpot@linaori@HeahDude@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp