Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle composed monolog-bridge activation strategy #336

Closed
wants to merge 1 commit into from

Conversation

pvgnd
Copy link
Contributor

@pvgnd pvgnd commented Feb 16, 2020

Related to symfony/symfony#35740

This PR instantiate the new HttpCodeActivationStrategy & NotFoundActivationStrategy with an inner strategy instead of an actionLevel

closes #369

@pvgnd pvgnd force-pushed the composed-activation-strategy branch from 3a07f6b to 7d1983e Compare February 16, 2020 18:50
@pvgnd pvgnd changed the title WIP: Handle composed monolog-bridge activation strategy Handle composed monolog-bridge activation strategy Feb 16, 2020
@pvgnd pvgnd force-pushed the composed-activation-strategy branch from 4bab351 to 9187278 Compare February 29, 2020 15:51
@pvgnd pvgnd force-pushed the composed-activation-strategy branch 2 times, most recently from 5d7d11c to 7660e8c Compare November 11, 2020 10:50
@pvgnd pvgnd requested a review from stof December 6, 2020 21:36
@nico-incubiq
Copy link

Travis builds are failing under the new version of xdebug, you can fix that with setting XDEBUG_MODE to "coverage" in the config. See https://travis-ci.community/t/xdebug-3-is-installed-by-default-breaking-builds/10748

@pvgnd
Copy link
Contributor Author

pvgnd commented Dec 18, 2020

@nico-incubiq Thanks I added a commit

@jokaorgua
Copy link

@pvgnd any chance you could fix the PR to pass all tests?
I think your fix is very important because this will fix a lot of deprecated warnings for all users who uses fingers_crossed in symfony 5.2

@pvgnd
Copy link
Contributor Author

pvgnd commented Dec 30, 2020 via email

@pvgnd pvgnd force-pushed the composed-activation-strategy branch from d962597 to a928f4e Compare January 3, 2021 15:46
@pvgnd pvgnd requested a review from jderusse January 3, 2021 16:05
@pvgnd pvgnd force-pushed the composed-activation-strategy branch from a928f4e to bbf53e9 Compare January 5, 2021 10:37
@nico-incubiq
Copy link

No update on this PR? @jderusse @stof do you think it can be merged?

@nicolas-grekas
Copy link
Member

@pvgnd can you please rebase?
/cc @lyrixx could you please have a look?
We have deprecations now :)

@pvgnd pvgnd force-pushed the composed-activation-strategy branch from bbf53e9 to 86646d5 Compare January 20, 2021 18:38
@pvgnd
Copy link
Contributor Author

pvgnd commented Jan 20, 2021

@nicolas-grekas done, branch rebased

Comment on lines +607 to +612
if (!class_exists(HttpCodeActivationStrategy::class)) {
$this->markTestSkipped('Symfony Monolog 4.1+ is needed.');
}
if (!\class_exists(SwitchUserTokenProcessor::class)) {
$this->markTestSkipped('Symfony Monolog 5.2+ is needed.');
}

Choose a reason for hiding this comment

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

Not sure why fabbot.io is not running, but either we use class_exists with or without a leading backslash 🧐 can you please check or reopen the PR to trigger fabbot again?

I am currently on a phone 📱

Thanks

Copy link
Member

Choose a reason for hiding this comment

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

Reopening does not trigger fabbot, apparently.

Copy link

@spirit-q2 spirit-q2 Jan 25, 2021

Choose a reason for hiding this comment

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

generally, it will work in both cases, but \class_exists() will be slightly faster, as parser will not check current namespace for such function and will check global namespace right away.

but in terms of code style consistency, IMO there shouldn't be such mix of usage. Either with backslashes, either without ;)

@jderusse jderusse mentioned this pull request Jan 23, 2021
Copy link
Member

@jderusse jderusse left a comment

Choose a reason for hiding this comment

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

I think the implementation could be simplified a lot (cf my comment)

Comment on lines -408 to +425
$activationDef = new Definition('Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy', [
new Reference('request_stack'),
$handler['excluded_404s'],
$handler['action_level']
]);
if ($isLegacyBridge) {
$activationDef = new Definition('Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy', [
new Reference('request_stack'),
$handler['excluded_404s'],
$handler['action_level']
]);
} else {
$activationDef = new Definition('Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy', [
new Reference('request_stack'),
$handler['excluded_404s'],
new Definition('Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy', [
$handler['action_level']
])
]);
}
Copy link
Member

Choose a reason for hiding this comment

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

IMHO all this can be simplified to

+ $activation = $handler['action_level'];
+ if (class_exists(SwitchUserTokenProcessor::class)) {
+    $action = new Definition(ErrorLevelActivationStrategy::class, [
+       $activation
+   ])
+ }

  // ...

  if (...) {
    $activationDef = new Definition('Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy', [
        new Reference('request_stack'),
        $handler['excluded_404s'],
-       $handler['action_level']
+       $activation
    ]);
    $activation = new Reference($handlerId.'.not_found_strategy');
  } elseif (...) {
    $activationDef = new Definition('Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy', [
        new Reference('request_stack'),
        $handler['excluded_http_codes'],
-       $handler['action_level']
+       $activation
    ]);
    $activation = new Reference($handlerId.'.http_code_strategy');
-  } else {
-    $activation = $handler['action_level'];
  }

{
if (\class_exists(SwitchUserTokenProcessor::class)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (\class_exists(SwitchUserTokenProcessor::class)) {
if (class_exists(SwitchUserTokenProcessor::class)) {

same everywhere

@derrabus derrabus closed this Jan 24, 2021
@derrabus derrabus reopened this Jan 24, 2021
@jderusse
Copy link
Member

Is fabbot enabled on this project?
I checked on other PR, fabbot is not running..

@adrienfr
Copy link

Is fabbot enabled on this project?
I checked on other PR, fabbot is not running..

Indeed, it seems like it's not enabled, regarding others PR for this project.

@jokaorgua
Copy link

jokaorgua commented Feb 8, 2021

@jderusse @adrienfr
I'm really sorry to disturb you but is there any movement in accepting this PR and making a new release with fixes?

@jderusse
Copy link
Member

jderusse commented Feb 8, 2021

@jderusse @adrienfr
I'm really sorry to disturb you but is there any movement in accepting this PR and making a new release with fixes?

Looks like the comments I have made, are not addressed.

@jokaorgua
Copy link

@pvgnd maybe you could help a bit to move this further ?

@spirit-q2
Copy link

Ping @stof 🙏

jderusse added a commit that referenced this pull request Feb 18, 2021
…vailable (jderusse)

This PR was merged into the 3.x-dev branch.

Discussion
----------

Use `ActivationStrategy` instead of `actionLevel` when available

Take over #336

Fixes #369

Commits
-------

7eaabac Use `ActivationStrategy` instead of `actionLevel` when available
@jderusse
Copy link
Member

closed in favor of #388

@jderusse jderusse closed this Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle deprecation of the actionLevel argument in finger crossed strategies