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

[SecurityBundle] fix allow_if expression service compilation to support custom functions#24309

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

Closed
dmaicher wants to merge3 commits intosymfony:2.7fromdmaicher:fix-23208

Conversation

@dmaicher
Copy link
Contributor

@dmaicherdmaicher commentedSep 24, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#23208
LicenseMIT
Doc PR-

I would like to discuss possibilities tofix#23208 (also see closed duplicate#24306).

The proposed solution in this PR is to simply not dump the parsed expression but simply the "raw" expressions

Question: Will this have a big negative performance impact? As far as I understand theExpressionLanguage should have a cache anyway for parsed expressions? Or not?

Idea: maybe we can add an additionalCacheWarmer that warms the cache for all those expressions?

Or is there a way to perform the compilation into parsed expressions at the very end of the container compilation when we could instantiate the actualExpressionLanguage service with all its custom extensions?

Edit: the new approach is to still dump the parsed expressions but we do it using the "real" expression language service with all custom extensions.

@dmaicher
Copy link
ContributorAuthor

@chalasr did you have a chance yet to look at this? Feedback welcome 😊

@chalasrchalasr requested review fromxabbuh and removed request forchalasrOctober 2, 2017 15:43
@chalasr
Copy link
Member

@dmaicher sorry, I didn't find time to look at this and I miss the whole picture, so I ping@xabbuh who participates to the fixed ticket already :)

dmaicher reacted with thumbs up emoji

@xabbuh
Copy link
Member

Can't we just move the serialisation of the expression language to a compiler pass that is processed after theAddExpressionLanguageProvidersPass?

@dmaicher
Copy link
ContributorAuthor

@xabbuh this seems to be working indeed 😊 👍 I will update the PR later today

@dmaicherdmaicher changed the base branch from2.7 to3.3October 11, 2017 13:02
$definition =$container->findDefinition('security.expression_language');
foreach ($container->findTaggedServiceIds('security.expression_language_provider',true)as$id =>$attributes) {
$definition->addMethodCall('addExpressionLanguageProvider',array(newReference($id)));
$definition->addMethodCall('registerProvider',array(newReference($id)));
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

To me this makes more sense than to "take a detour" via the ExpressionVoter to extend the ExpressionLanguage service.

Should not break BC?

@dmaicher
Copy link
ContributorAuthor

@xabbuh before I will fix the tests + add more tests: Is this what you meant?

Also I had to change the base to 3.3 as we cannot set priorities for compiler passes before 😢

@xabbuh
Copy link
Member

RemovingParseSecurityExpressionsPass and doing the work inAddExpressionLanguageProvidersPass::process() should work on 2.7 too, right?

@dmaicher
Copy link
ContributorAuthor

You mean doing that only for 2.7 and 2.8? Seems a bit wrong though to put that intoAddExpressionLanguageProvidersPass as the name suggests it only adds/processes the custom providers 😕

@xabbuh
Copy link
Member

Alternatively, we can add the new compiler pass to the FrameworkBundle instead. This shouldn't be a big problem as we already have the handling for registering custom provider there.

@dmaicher
Copy link
ContributorAuthor

@xabbuh indeed that seems better. Done 😉

->setPublic(false)
->addArgument($expression)
->addArgument(serialize($this->getExpressionLanguage()->parse($expression,array('token','user','object','roles','request','trust_resolver'))->getNodes()))
->addTag('security.expression.unparsed')
Copy link
Member

Choose a reason for hiding this comment

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

I don't really like this tag name. Can't we just use something likesecurity.expression?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

yeah why not 😊 Done 👍

return;
}

$expressionLanguage =$container->get('security.expression_language');
Copy link
Member

Choose a reason for hiding this comment

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

findDefinition()

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

No this should actually get the instantiated service 😉

Copy link
Member

Choose a reason for hiding this comment

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

Oh hm, I missed that. To be honest I am not really happy with having compiler passes that force the creation of the actual service during compilation. Can't we solve the problem by letting the serialization happening in a cache warmer where the service is actually available?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I see your point. I'm also not 100% happy with this solution.

The only other option I see is to use a proper persisting cache by default for the expression language service. Currently it only uses anArrayAdapter:

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php#L37

https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml#L82

On 3.3+ we could use the system cache pool for it?

And then we could add aCacheWarmer for it.

Or do you have another idea?

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, I had something like that in mind.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I will have a look and maybe also prepare some benchmarks to see the impact of the change

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

$expressionLanguage =$container->get('security.expression_language');

foreach ($container->findTaggedServiceIds('security.expression')as$id =>$attributes) {
$defition =$container->getDefinition($id);
Copy link
Member

Choose a reason for hiding this comment

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

typo:$definition

@dmaicher
Copy link
ContributorAuthor

will work on a different solution within a separate PR

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh left review comments

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@dmaicher@chalasr@xabbuh@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp