Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/swiftmailer 6 compat #237

Closed

Conversation

thirsch
Copy link
Collaborator

@thirsch thirsch commented Sep 7, 2020

We have added support for swiftmailer 6 by providing a second version of sfMailer that is compatible with swiftmailer 6. As we are installing symfony via composer, it's no issue for us to not using the submodule version. But is that ok for the upstream too?

Updating a previous symfony1 installation might require to change any static access from sfMailer:: to sfMailerBase::. But before adjusting the doc etc. I wanted to check with you if this branch is of interest for you.

Solves #161

(cherry picked from commit 3622f22)
… Submodule for swiftmailer not required as it is also a dependency within composer.

(cherry picked from commit ba2dfe3)
(cherry picked from commit 2e00caa)
(cherry picked from commit 90c5a42)
@mentalstring
Copy link
Contributor

FWIW,

I'd welcome support for Swiftmailer 6, specially if this also maintains support for v5.

I would be fine with not using the submodule approach, if that's the only roadblock.

@thirsch
Copy link
Collaborator Author

thirsch commented Sep 8, 2020

I came to another, way easier approach without breaking any backward compatibility within the code. Maybe we can also keep the submodule and if the user is using the submodule, it will simply install ~5.2 and using the composer it will install ~5.2 or ~6.0 depending on the available php version. Let me do some tests for the changes and the submodule idea.

…on via composer will not install submodules. Yeay!
@thirsch
Copy link
Collaborator Author

thirsch commented Sep 8, 2020

Yes, it's working! With the current change we are backward compatible and we even can keep the submodule approach!

To have the tests working again, we would need #236 first. After that, we can check the status of the mailer tests.

Copy link
Contributor

@alquerci alquerci left a comment

Choose a reason for hiding this comment

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

Hello @thirsch ,

Thank you to propose this compatibility.

Look at line comments where I expose the minimum change to add SwiftMailer version 6 compatibility.

No need to introduce sfMailerBase.

Also the submodule should be left untouched.

*
* @return int|false The number of sent emails
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the type hint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, that was way to simple... ;-) I wasn't aware, that you can remove the typehint and be less specific while extending from another class.

Copy link
Contributor

Choose a reason for hiding this comment

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

You rise me a doubt. But for sure the test have always right, and the result may depend on the PHP version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it's working. On a new codebase I would not do prefer it that way, but on the legacy stuff it's sufficient to get the compat for swiftmailer 6 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, however, even on new codebase as the type constraint is respected with the call on the parent and the transport.

There is a goal to avoid using language version specific code as much as possible to avoid useless complexity.

But that's another story depending of the codebase. I give you me point of view.

@@ -5,7 +5,7 @@
"license": "MIT",
"require": {
"php" : ">=5.3.0",
"swiftmailer/swiftmailer": "~5.2"
"swiftmailer/swiftmailer": "~5.2|~6.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

The dependency constraint should be more strict like that => ^6.0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, could you please explain the difference to me? From what I understood on https://getcomposer.org/doc/articles/versions.md#next-significant-release-operators, it will be the same and only differ, if I would introduce the third digit.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ~ include 7.0@dev but not with ^.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ~ include 7.0@dev but not with ^.

Hm... Really?

I think they explicitly mention that it will not install versions having major number different from 6 @alquerci

Note: Although 2.0-beta.1 is strictly before 2.0, a version constraint like ~1.2 would not install it. As said above ~1.2 only means the .2 can change but the 1. part is fixed.

https://getcomposer.org/doc/articles/versions.md#tilde-version-range-

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, indeed I wasn't understand in details the difference.

Now yes.

The ^ operator behaves very similarly, but it sticks closer to semantic versioning, and will always allow non-breaking updates.

https://getcomposer.org/doc/articles/versions.md#caret-version-range-

#learningAllDays

@thirsch
Copy link
Collaborator Author

thirsch commented Sep 9, 2020

Hello @thirsch ,

Thank you to propose this compatibility.

Look at line comments where I expose the minimum change to add SwiftMailer version 6 compatibility.

No need to introduce sfMailerBase.

Also the submodule should be left untouched.

Thanks @alquerci, I'll close this pr and open a new one with only the relevant changes and without removing the submodule.

@thirsch thirsch closed this Sep 9, 2020
@thirsch thirsch deleted the feature/swiftmailer-6-compat branch January 12, 2023 18:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants