Problem/Motivation
Once upon a time, update.fetch.inc included all the code that runs while fetching new available update data and related support methods. Over time, folks have OO-ified this into src/UpdateFetcher.php, src/UpdateProcessor.php and others. The once huge update.fetch.inc now contains a single, lonely function, _update_cron_notify().
Proposed resolution
- Move the brains from
_update_cron_notify()toDrupal\update\Hook\UpdateCronHooks. - Move the mail sending code to a new
Drupal\update\MailHandlerto make it swappable (for the same reasons as #3539178: Extract _user_mail_notify() into a user NotificationHandler). - Remove update.fetch.inc
Remaining tasks
- Implement the proposed resolution.
- Reviews.
- RTBC.
- Commit.
User interface changes
N/A
API changes
TBD. Nothing public, since _update_cron_notify() is prefixed with an underscore and therefore officially considered internal.
Data model changes
N/A
Release notes snippet
TBD, probably none.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3125013
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3125013-deprecate-updatecronnotify-and
changes, plain diff MR !12908
Comments
Comment #2
abhijeet.kumar2107 commentedComment #3
abhijeet.kumar2107 commentedComment #12
znerol commentedComment #13
znerol commentedMoving this under the umbrella of #1803948: [META] Adopt the symfony mailer component.
Comment #14
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #15
znerol commentedFixed a misnamed variable. The approach in #3539178: Extract _user_mail_notify() into a user NotificationHandler changed a little bit (internal service, no interface). Let's see how that goes over there and adapt here if necessary.
Comment #16
smustgrave commentedCan we get a change record for the new interface?
Comment #17
anmolgoyal74 commentedI have added the change record. Probably It would need more updates. Please review.
Comment #18
smustgrave commentedLooking at the MR vs the CR think we need to deprecate _update_cron_notify before we can remove it.
Comment #19
dwwI’m not so sure. It’s a function that starts with
_which means it’s explicitly not API. No one should be calling this manually. If they are, they’re “doing it wrong” and if their code breaks when we remove it, it’s on them for calling an internal, non-API function.Comment #20
dwwThat said, I think the CR isn’t documenting what anyone might care to know. It should be discussing the addition of core/modules/update/src/MailHandlerInterface.php not talking about “deprecation” since yeah, we’re not deprecating anything, we’re refactoring internal code.
Comment #21
znerol commentedSimilar discussion over in #3539178: Extract _user_mail_notify() into a user NotificationHandler . I do not have much of an opinion, but we should do it consistently here and in the user module.
Also in the other issue we went without an interface.
Comment #22
smustgrave commentedJust in case we don’t end up needing deprecation may want to update the title too
Comment #23
dwwYeah, if we need no interface, happy to not need a CR here at all. Agree we should be consistent.
Comment #25
berdirWe've made exceptions on the underscore-prefixed rule before, when it's not too much trouble and used in contrib. we did that with _field_multiple_value_form_sort_helper() and I think it makes sense for _user_mail_notify() because there are dozens of usages of that in contrib, with that one there's some disagreement on how far that BC logic should go though. That one probably should always have been an API, it is a pretty common thing that other modules need to do as proven by the usages.
That said, this one seems pretty much unused, all I could find is a bunch of copy-pasted and bogus @see references from copied hook_mail() implementations: https://git.drupalcode.org/search?group_id=2&scope=blobs&search=_update_...
IMHO we don't need to be consistent but can decide on a case-by-case basis for these functions.
If it were doing anything else but sending mails, I'd suggest to just inline it into the hooks class, that's what we did in other cases too. We can keep the old code as-is and deprecate it without attempting to call the new code. However, the semi-secret reason that znerol is doing that MailHandler service here is that this helps with the completely separate effort to replace hook_mail with the new symfony mailer API, the idea there is that the experimental module would, if enabled, replace/subclass all those services to use the new API until it's no longer experimental. But that won't work in all cases anyway, so I'm undecided myself and can live with either the service or inlined in the hooks class. Either way, +1 on no interface.
Comment #26
znerol commentedApplied the same approach as in #3539178-22: Extract _user_mail_notify() into a user NotificationHandler to get rid of the interface and still permit a subclass with a completely different kind of mail manager.
Comment #27
znerol commentedUpdated the CR.
Comment #28
znerol commentedShould we mark
Drupal\update\MailHandleras@internal.Comment #29
nod_Updated search link for #25: _update_cron_notify seems like it's not used anywhere
Comment #30
znerol commentedAdapt to approach discussed in #3539178: Extract _user_mail_notify() into a user NotificationHandler.
Comment #31
nicxvan commentedComment #32
nicxvan commentedThere are a couple of contrib modules including the file though which is weird because they don't use the function.
https://git.drupalcode.org/project/dash/-/blob/6fc17292c04d903f1285db629...
That whole method is... interesting to say the least.
I think this means we should deprecate the file, although in one of the locale issue alexpott said we should explicitly not deprecate the file and just delete the file when ready, the immediate white screen is a better signal.
So in not sure we change anything now that I think further.
Comment #33
znerol commentedinclude()doesn't fatal when a file is missing.require()does.Comment #34
nicxvan commentedThat's right, so nothing to change, I'll review it again when I have a moment.
Comment #35
dwwApologies for the noise. Pushed a rebase to re-test #3576458: [regression] Subsystem and Topics maintainers require access to re-run, trigger, or view tests. Alas, still running in the parent project. 😢
https://git.drupalcode.org/project/drupal/-/pipelines/779292
Comment #36
nicxvan commentedI took a careful look at this. All of the code that was moved has been faithfully moved.
The actual send code has been moved with the reasons stated in 25.
This may get kicked back for consistency and require deprecation. But as noted, it is not used anywhere, and there is only the one function in that file so I think we can make the exception and clean up the whole include.
I reviewed the IS and the CR.
The CR is a bit sparse, but I question if we need it since we're not even deprecating it.
Comment #37
dwwResolved 1 thread. Opened a few others. Mostly nits, and possible scope creep that should be follow-ups.
But NW since there's an
{@inheritdoc}on a method with no parent docs to inherit. At least that one should be fixed before RTBC. The others I'm open to moving to follow-ups (or fixing here).Thanks!
-Derek
Comment #38
znerol commentedComment #39
dwwIndeed, that was my concern. But I'm prepared to let it go for now. The method is in fact
protected. So if we made it public in the future, we can revisit.Thanks for the fixes! Almost there. 😅 2 more minor suggestions, then this is RTBC to my eyes.
Thanks again!
-Derek
Comment #40
dwwI think I've squeezed every improvement out of this I can ethically request. 😂 This seems great. We can definitely handle any other potential improvements in follow-ups.
Title and summary are still accurate.
I'm not sure we need/want the CR, but the draft is there.
First pass at saving credit: @znerol for the code, myself and @nicxvan for reviews. The other contributions here don't seem significant enough for credit. But happy to be wrong if the committer feels otherwise.
Thanks!
-Derek
Comment #41
godotislatePerformance test needs tweaking.
Also a question on the MR.
Comment #42
berdirI don't see why this would affect asset aggregation, maybe a random fail? Agree on the lazy services, most cron executions won't need them.
Comment #43
godotislateRe-running again now, but I think it's failed at least twice.
Comment #44
berdirIt did fail again yes, but this was a few commits behind and I think it just managed to hit the HEAD fail introduced by #3502993: Convert Navigation messages component to SDC, there was a follow-up commit to that that fixed that test. I rebased it through the UI to confirm.
Comment #45
znerol commentedComment #46
berdirFeedback has been addressed.
Comment #50
godotislateConsulted with @quietone and @catch about the how the service closure properties were documented, such as
Decision was that this is fine, though we may open a coding standards issue if there's a way we want to standardize going forward.
Committed and pushed to 4081563 main and df22840 to 11.x. Thanks!