Problem/Motivation

Those classes use custom construction and configuration code, using class names. That's a typical pattern for plugins. Or services.

Additionally, the naming is strange, I don't remember why we went with this name.

Proposed resolution

What it essentially represents is a mail spool entry, and we renamed the methods there to *Mail(), so naming these Mail would make more sense. We could also rename SpoolList to MailList.

We might also need a new concept of how we configure/construct them. I'm not sure the concept of entity type specific implementation still makes sense in 8.x, and there also isn't really an option to use something else. For that to actually make sense, we'd need a new column in the database that indicates the plugin that should be used?

So... maybe we should just drop built-in pluggability there completely? We still have a test implementation that we're passing in directly somewhere, but that should still work.

Which leaves us with caching. Where just having a service would be nice, but then we lose the current ability to configure it in the UI. Question is, do we need that? We could just document how to add a site specific service override and provide two implementations?

Thoughts?

Remaining tasks

User interface changes

API changes

Comments

berdir’s picture

Issue summary: View changes
miro_dietiker’s picture

Service: I think caching is is not a global topic. An active site might have some newsletter that is similar for all recipients except token replacement. And then a second mail that is highly personalised.

Does your proposal cover for this?

Rest yeah, UI is not soo needed and slim code is possibly a much better fit.
But also here i'm not sure about how things work if multiple cases coexist on the same system.

berdir’s picture

No, if we just have a service, then that would be global. It is currently global too. If we want to keep that possibility then we need plugins.

berdir’s picture

Status: Active » Needs review
StatusFileSize
new41.8 KB

Got started here. Renamed everything to Mail*

Source/Mail cache hook/discovery/configurability is gone, it is a service now.

The answer to your concern is services and dependency injection. the mail cache is now injected into the mail class, if you want to use a different one, just create your own mail objects and pass it in. We do it in tests, and it is also possible to override the relevant services and use a different object. Might require to copy & paste a bunch of code right now but we can also improve that.

Status: Needs review » Needs work

The last submitted patch, 4: simplenews-source-mail-rename-2481151-4.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new41.77 KB
new343 bytes

...

Status: Needs review » Needs work

The last submitted patch, 6: simplenews-source-mail-rename-2481151-6.patch, failed testing.

miro_dietiker’s picture

Priority: Major » Critical

Promoting to critical since it significantly affects APIs.

berdir’s picture

Status: Needs work » Fixed

This patch is big enough, test fails were just the usual random fails. Committed. We'll need separate issues to rely more/only on default render caching.

  • Berdir committed 2168c9a on 8.x-1.x
    Issue #2481151 by Berdir: Make source and source caches plugins/services...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.