Skip to content

[MonologBridge] Monolog 2 compatibility #27905

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

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Jul 9, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets #27857
License MIT
Doc PR N/A

See #27857 for the discussion.

This PR adds return types to methods that need to have one in Monolog 2.

Notes:

  • The PR will break userland handlers that extend handlers from Monolog Bridge.
  • I was unable to come up with a php 7.1 compatible version of SwiftMailerHandler that works with Monolog 1 and Monolog 2 because a method we're overriding now has a string type-hint on a parameter that wasn't there before. I've „solved“ this with a version switch, but I feel dirty doing this. 🙈 If you have a better solution, please enlighten me.

@Seldaek
Copy link
Member

Seldaek commented Nov 19, 2018

Hey, I'd appreciate if you can check how this fares against latest dev-master of monolog. Interfaces are now considered stable and while there are a few things I still want to look at before releasing, I'm trying to wrap up soon (and definitely before Symfony 4.3). I'd like to make sure it won't prevent Symfony projects from upgrading before I tag anything though.

@stof
Copy link
Member

stof commented Nov 20, 2018

* SwiftMailerHandler is broken with Monolog 2 and php 7.1.

what is broken here ?

@derrabus
Copy link
Member Author

Hey, I'd appreciate if you can check how this fares against latest dev-master of monolog.

@Seldaek I can look into this on the weekend.

@derrabus
Copy link
Member Author

what is broken here ?

@stof see this comment

@derrabus derrabus force-pushed the monolog-2-compat branch 4 times, most recently from ebffece to 75c52f2 Compare December 2, 2018 11:49
@derrabus
Copy link
Member Author

derrabus commented Dec 2, 2018

I've updated the PR for the latest master of Monolog.

@derrabus derrabus force-pushed the monolog-2-compat branch 3 times, most recently from 7e243b7 to 085cf24 Compare April 6, 2019 16:26
@derrabus derrabus changed the title [MonologBridge] WIP: Monolog 2 compatibility [MonologBridge] Monolog 2 compatibility Apr 6, 2019
@derrabus
Copy link
Member Author

derrabus commented Apr 6, 2019

I've updated the PR during the EU-FOSSA hackathon. With my modifications, I was able to integrate Monolog 2 into a Symfony 4 application.

@derrabus
Copy link
Member Author

derrabus commented Apr 6, 2019

@Seldaek Have you ever considered making php 7.2 a requirement for Monolog 2? That would save us quite some pain here. 😅

@Seldaek
Copy link
Member

Seldaek commented Apr 8, 2019

I already bumped from 7.0 to 7.1.. I am not sure what the 7.2 change would help with, but I feel like that's a bit much. I really need to get there with finalizing monolog 2 though :/

@stof
Copy link
Member

stof commented May 16, 2019

@Seldaek PHP 7.2 is less strict than PHP 7.1 about adding/removing typehints in child classes for some cases. See the PR description.

@Seldaek
Copy link
Member

Seldaek commented May 16, 2019

Ok well I guess it could be considered as the release was delayed so much anyway.. But it means it won't be compatible with Symfony 4 requirements at all then.

@derrabus
Copy link
Member Author

Since it does not look like this will be merged into 4.3 anymore: I would suggest to rebase the patch against master, set all handlers to final and apply the interface changes required for Monolog 2. That would mean that version 5.0 of the bridge would be compatible with Monolog 1 and 2 while the Bridge 4.4 would support Monolog 1 only.

@Seldaek
Copy link
Member

Seldaek commented Jun 30, 2019

@derrabus if 4.4 is not an option then I guess this sounds good. I will try and push for a 2.0 again.. sorry for the delay.

@Seldaek
Copy link
Member

Seldaek commented Jun 30, 2019

Sorry my comment above was regarding the symfony 5/4 note, but regarding monolog requiring php 7.2 I am still not 100% sure. Will need to think about it some more. I'll add an issue too to see if anyone has feedback.

@derrabus derrabus force-pushed the monolog-2-compat branch from 0f05439 to ca1cfec Compare July 1, 2019 09:47
@derrabus
Copy link
Member Author

derrabus commented Jul 1, 2019

I've updated the PR for master. It should be safe to merge now.

regarding monolog requiring php 7.2 I am still not 100% sure.

If we made Monolog 2 support a Symfony-5-only feature, the php requirement of Monolog would not matter anymore because Symfony 5 itself will require php 7.2.

@Seldaek
Copy link
Member

Seldaek commented Jul 8, 2019

Looks all good to me from a quick glance..

@nicolas-grekas
Copy link
Member

There's no way to M2 compatible with SF4.4, right?
This means M1 should accept bug fixes for 3-4 more years ideally.

@Seldaek
Copy link
Member

Seldaek commented Jul 8, 2019

I think it was mostly possible, at least if you are on php 7.2, if not I think then there was a hack needed for swiftmailer handler? @derrabus probably has more of an overview..

I'd definitely prefer having Symfony 4.4 support Monolog 2 as well, but regardless Monolog 1 is super stable at this point so keeping maintenance up for a few more years is not that much work.

@fabpot
Copy link
Member

fabpot commented Jul 8, 2019

Thank you @derrabus.

@fabpot fabpot merged commit ca1cfec into symfony:master Jul 8, 2019
fabpot added a commit that referenced this pull request Jul 8, 2019
This PR was merged into the 5.0-dev branch.

Discussion
----------

[MonologBridge] Monolog 2 compatibility

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27857
| License       | MIT
| Doc PR        | N/A

See #27857 for the discussion.

This PR adds return types to methods that need to have one in Monolog 2.

Notes:
* The PR will break userland handlers that extend handlers from Monolog Bridge.
* I was unable to come up with a php 7.1 compatible version of `SwiftMailerHandler` that works with Monolog 1 and Monolog 2 because a method we're overriding now has a `string` type-hint on a parameter that wasn't there before. I've „solved“ this with a version switch, but I feel dirty doing this. 🙈  If you have a better solution, please enlighten me.

Commits
-------

ca1cfec Monolog 2 compatibility.
@derrabus
Copy link
Member Author

derrabus commented Jul 8, 2019

There's no way to M2 compatible with SF4.4, right?

Monolog 2 forces us to add return types to several classes. That is a BC break if userland code extends classes from the Monolog bridge. If we wanted to have Monolog 2 in Symfony 4.4, we could either…

  • deprecate the affected classes and introduce new ones with return types or…
  • document the BC break and pray that userland code does not extend the bridge classes.

@derrabus derrabus deleted the monolog-2-compat branch July 8, 2019 10:38
@nicolas-grekas
Copy link
Member

  • or conditionally load an implementation with types when PHP 7.2 is used. but let's make things simple for now at least - until someone explains why the current way is not enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants