73256[TASK] Modernize code in the Mail system
Commit message
Review
-
Code review CR +2 Done
- Christian Kuhn +2
- Stefan Bürk +1
-
Verified V +2 Done
- Christian Kuhn +2
- Stefan Bürk +1
- core-ci +1 CI
Issues 1
Files 10
- Build/phpstan/phpstan-baseline.neon+0 −5
- typo3/sysext/core/Classes/Mail/Event/AfterMailerInitializationEvent.php12+1 −7
- typo3/sysext/core/Classes/Mail/FileSpool.php8+13 −48
- typo3/sysext/core/Classes/Mail/FluidEmail.php5+9 −22
- typo3/sysext/core/Classes/Mail/Mailer.php12+20 −43
- typo3/sysext/core/Classes/Mail/MailMessage.php+3 −8
- typo3/sysext/core/Classes/Mail/MboxTransport.php2+12 −25
- typo3/sysext/core/Classes/Mail/MemorySpool.php2+4 −18
- typo3/sysext/core/Classes/Mail/TransportFactory.php+4 −14
- typo3/sysext/core/Tests/Unit/Mail/MailerTest.php+27 −46
Review log 5673
Show 3748 earlier messages
-
crell uploaded patch set 1 02/01/22, 00:06
-
crell uploaded patch set 2 02/01/22, 00:10
-
core-ci voted on patch set 1 V -1 02/01/22, 00:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22840
-
core-ci voted on patch set 2 V +1 02/01/22, 00:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22841
-
Mathias Brodala commented on patch set 2 CR -1 02/01/22, 08:10
FluidEmail.php:47Since this is technically assigned in the constructor, could it be readonly?FakeFileSpoolFixture.php:29This would be a behavior change since now GeneralUtility::mkdir_deep() would be invoked for this path even though the purpose is clearly faking a path, no matter if it exists. -
Oliver Klee commented on patch set 2 02/01/22, 12:15
Mailer.php:42When we add native type declarations, please let's also always remove the PHPDoc type annotation where it doesn't provide additional information. -
crell commented on patch set 2 02/01/22, 17:04
AfterMailerInitializationEvent.php:28ReplyI believe the accessor method is redundant and obsolete and can be removed in a future version. I didn't want to make that breaking change right now, though.FluidEmail.php:47ReplyHm, I think so. I'll try it and see if the bot approves.Mailer.php:42ReplyAckFakeFileSpoolFixture.php:29ReplyHrm. That's a challenge then as you cannot set a readonly property from a child class. (IMO this is a design flaw in RO properties.) The alternatives would be: 1. Don't make $path readonly. 2. Try to use a closure binding to dance around the inheritance issue. Option 2 would be this line: (fn() => $this->path = $path)->bindTo($this, parent::class)(); Any preferences? I don't feel very strongly either way. -
Mathias Brodala commented on patch set 2 02/01/22, 17:08
AfterMailerInitializationEvent.php:28ReplyMakes sense, thanks.FakeFileSpoolFixture.php:29ReplyThen we should not make `$path` readonly ATM. This is another good example why inheritance is bad. If FakeFileSpoolFixture did decorate FileSpool instead (and forward calls accordingly) this would be no issue. -
crell uploaded patch set 3 02/01/22, 17:20
-
core-ci voted on patch set 3 V -1 02/01/22, 17:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22886
-
crell commented on patch set 3 02/01/22, 18:06
FakeFileSpoolFixture.php:29ReplyNot going to disagree there. :-) OK, I'll switch it back in the next patch. -
crell uploaded patch set 4 02/01/22, 18:06
-
core-ci voted on patch set 4 V -1 02/01/22, 18:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22890
-
crell uploaded patch set 5 02/01/22, 19:10
-
core-ci voted on patch set 5 V +1 02/01/22, 19:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22891
-
crell commented on patch set 5 02/01/22, 19:35
FluidEmail.php:47ReplyPHPStan disapproves, because "technically" is not good enough. Rather than fight with Stan I just backed that change out for now. -
Oliver Klee wrote 02/01/22, 19:45
Removed cc Oliver Klee. -
crell rebased onto patch set 6 02/01/22, 20:21
-
core-ci voted on patch set 6 V +1 02/01/22, 20:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22892
-
Simon Gilli commented on patch set 6 CR -1 02/02/22, 11:58
Not sure about some minor changes, please check my comments.Mailer.php:59This condition makes sense for a static field only.Mailer.php:73This removal changes the whole bahavior. Transport should only be initialized if not injected. -
crell commented on patch set 6 02/02/22, 15:55
Mailer.php:59ReplyHonestly I have no idea what is going on with that line; it's in the existing code now, but it's either pointless or fulfilling some use case I don't understand. My follow up patch is going to remove the property entirely, but I can't do that here, so I was trying to minimize the impact. If you think it's safe to remove I can try to do so.Mailer.php:73ReplyThis is handled by the parallel change in initializeTransport() to use ??=, which is logically equivalent to "set only if it's not null". The net logical effect should be the same. (It's effectively the same as moving the if check into the method.) If $transport is set by the promoted property, the ??= will turn into a noop. If it is set to null by the promoted property, initializeTransport() will be called and set the value now. I believe the net effect is no behavior change. -
Stefan Bürk commented on patch set 6 02/02/22, 16:08
Mailer.php:59Replysee getRealTransport(). mailSettings is used to switch from spool transport to realtransport. Would guess this is needed for the spooler cli when working the queue and really send the mails then. Should be kept in mind. -
Simon Gilli commented on patch set 6 02/02/22, 18:42
Mailer.php:59ReplyWell, it's in the constructor, definitively pointless imho. But as it's existing code I'm either fine to remove it here or later, does not hurt in any case.Mailer.php:73ReplyMore talking about the other stuff here, e.g. mail settings injection, which is originally only done having the transport set to null or the later transport initialization. Looks problematic to me! -
Simon Gilli commented on patch set 6 02/02/22, 18:51
Mailer.php:59ReplyDone -
Simon Gilli commented on patch set 6 02/02/22, 18:53
Mailer.php:73ReplyDone -
Simon Gilli voted on patch set 6 CR +1 02/02/22, 18:53
-
Oliver Klee updated the commit message in patch set 7 02/02/22, 20:26
-
core-ci voted on patch set 7 V +1 02/02/22, 20:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22923
-
crell commented on patch set 7 02/02/22, 20:43
Mailer.php:73ReplyFor others coming to this later: Simon and I chatted and concluded that yes, the code is still logically equivalent to what was there before. It's just not immediately obvious from the constructor since the null checks all moved around and into another method. But it is a no-functional-change refactor. -
Guido Schmechel commented on patch set 7 02/03/22, 11:15
FileSpool.php:60Has the line slipped here? (I know, super important :-D) -
crell commented on patch set 7 02/03/22, 16:05
FileSpool.php:60ReplyPHPDoc allows descriptions to be on the following line, which is overall easier to read and gives you more room. -
Guido Schmechel commented on patch set 7 CR +1 02/03/22, 16:08
FileSpool.php:60ReplyOk. That had irritated me only, because I knew so far that rather in a line. -
Stefan Bürk commented on patch set 7 02/03/22, 17:49
AfterMailerInitializationEvent.php:38an a @todo that this may be deprecated/removed as it is now redudant through the change to public readonly constructor promotion (and would help other reviewers understant the change.FileSpool.php:60ReplyThat looks weired. And even .. "more room needd for three words and a point" so lets add an extra line and distractincting params ? Before constructor parameter promotion, I would hav said change the variable name to "$spoolPath" and remove the comment at all. But that would now change the internal property name and eventuall needs more changes. However, plese write it right of the variable. (I know PHPdoc "allows" this, but smells.)FluidEmail.php:66nice. -
Stefan Bürk commented on patch set 7 02/03/22, 17:51
FileSpool.php:60ReplyOr at least remove it here and extend the > Create a new FileSpool with message storage in specified path ($path). -
crell uploaded patch set 8 02/03/22, 18:02
-
Stefan Bürk commented on patch set 8 02/03/22, 18:07
larry, it seems you repushed an old patchset or something like that. avoid the ending "." in the commit message, you readded it.you should avoid the ending ".". Oliver has pushed a patchset removing it, you pushed it and reverted that change. Was a topic and explained by Oliver already in another patch why. -
core-ci voted on patch set 8 V +1 02/03/22, 18:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22965
-
crell commented on patch set 8 02/03/22, 21:42
Reply
Ugh. I thought I fixed that locally. Will double check when I next reroll.AfterMailerInitializationEvent.php:38ReplyAckFileSpool.php:60ReplyI went with removing the whole redundant block and just having the richer description line.FluidEmail.php:66ReplyAck -
crell uploaded patch set 9 02/03/22, 21:42
-
core-ci voted on patch set 9 V +1 02/03/22, 21:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22977
-
Simon Gilli commented on patch set 9 CR -1 02/04/22, 17:07
FileSpool.php:61? missingMemorySpool.php:61? missing -
crell uploaded patch set 10 02/04/22, 17:28
-
core-ci voted on patch set 10 V +1 02/04/22, 17:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23012
-
crell commented on patch set 10 02/04/22, 18:00
FileSpool.php:61ReplyAckMemorySpool.php:61ReplyAck -
crell uploaded patch set 11 02/04/22, 18:42
-
core-ci voted on patch set 11 V +1 02/04/22, 18:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23018
-
Simon Gilli commented on patch set 11 V +1 CR +1 02/04/22, 19:40
Thanks Larry! -
Benjamin Franzke commented on patch set 11 CR -1 02/04/22, 22:15
AfterMailerInitializationEvent.php:331) Deprecations require a Deprecation.rst 2) We discussed "public readonly" usage in the last core merger meeting. It was kinda decided against it, because public properties are hard to deprecate with deprecation messages, while that's possible for getter methods. So the basic problem is that PHP doesn't support first-level getter methods like JavaScript does. (I also like the simplicity, still, current decision is to keep getters for public access like this.)
-
Benjamin Franzke commented on patch set 11 02/04/22, 22:16
AfterMailerInitializationEvent.php:33Replyjust to be clear: > with deprecation messages, while that's possible for getter methods I'm talking about trigger_error(…, E_USER_DEPRECATED) – which is, btw, also missing here. -
crell commented on patch set 11 02/04/22, 23:24
AfterMailerInitializationEvent.php:33ReplyAck -
crell uploaded patch set 12 02/04/22, 23:24
-
core-ci voted on patch set 12 V +1 02/04/22, 23:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23025
-
Christian Kuhn commented on patch set 12 CR -1 02/05/22, 06:50
AfterMailerInitializationEvent.php:33Replycomment from Benjamin is still open and not fixed. -
Christian Kuhn commented on patch set 12 02/05/22, 07:12
AfterMailerInitializationEvent.php:33ReplyI'm -1 to this change here for a different reason anyway: The getter exists already in the event. events are tailored for 3rd party consumers. Whenever we change them, it's a deprecation or breaking thing by definition. Dropping getMailer() and having a public property instead has close to zero additional value, but still forces consumers to adapt. Imho there is not enough reason to changes this now, except code-beautiness. Did I miss something? -
Simon Gilli commented on patch set 12 02/05/22, 13:30
AfterMailerInitializationEvent.php:33ReplyFor 2), is this information publicy available somewhere? I absolutely can follow this decision, makes sense to me too. -
crell uploaded patch set 13 02/07/22, 16:08
-
crell commented on patch set 12 02/07/22, 16:08
AfterMailerInitializationEvent.php:33ReplyThis particular spot is indeed entirely aesthetic, so I'll back out the method deprecation for now. Promoting the constructor parameter is a no-brainer, though. -
core-ci voted on patch set 13 V +1 02/07/22, 16:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23151
-
Nikita Hovratov uploaded patch set 14 02/07/22, 18:46
-
Nikita Hovratov voted on patch set 14 V +1 CR +1 02/07/22, 18:47
-
crell commented on patch set 14 02/07/22, 18:53
MboxTransport.php:34Uh, the dispatcher is not the file into which to write mail. :-) Frankly we an probably just kill the whole docblock. -
core-ci voted on patch set 14 V +1 02/07/22, 19:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23159
-
Christian Kuhn commented on patch set 14 02/07/22, 20:52
MboxTransport.php:34ReplyDone -
Christian Kuhn uploaded patch set 15 02/07/22, 20:53
-
Christian Kuhn uploaded patch set 16 02/07/22, 20:57
-
core-ci voted on patch set 15 V +1 02/07/22, 21:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23166
-
core-ci voted on patch set 16 V -1 02/07/22, 21:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23167
-
Christian Kuhn commented on patch set 16 CR -1 02/07/22, 21:10
... will fix phpstan in 5 minutes. -
Stefan Bürk uploaded patch set 17 02/07/22, 21:28
-
core-ci voted on patch set 17 V +1 02/07/22, 21:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23169
-
Stefan Bürk voted on patch set 17 V +1 CR +1 02/07/22, 21:41
-
Christian Kuhn voted on patch set 17 V +2 CR +2 02/07/22, 21:41
-
Christian Kuhn merged patch set 18 02/07/22, 21:41
AfterMailerInitializationEvent.php:28