Active
Project:
Drupal core
Version:
main
Component:
mail system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
22 Aug 2014 at 09:17 UTC
Updated:
18 Aug 2020 at 00:06 UTC
Jump to comment: Most recent
The static method MailFormatHelper::htmlToMailUrls uses global variables $base_url and $base_path. This prevents the method from being unit tested.
See #7
Comments
Comment #1
dawehnerSo I would argue that those should actually not be static methods?
Comment #2
sutharsan commentedSince it requires a service, I think I agree. But I have not enough experience in this field to see other alternatives. So I am open for suggestions and would like some else to decide on this.
Comment #3
mile23htmlToMailUrls()is protected and supportshtmlToText().htmlToText()should be responsible for determining$base_pathand$base_urland then passing them in.So: Change
htmlToMailUrls()to require two more arguments, and then changehtmlToText()to determine the contexts. It can accept theRequestas an optional argument (preferred), or could use\Drupalto glean the request from services.Comment #5
m1r1k commentedComment #6
m1r1k commentedComment #7
berdir+1 to #1 btw. What we could do is introduce a new non-static version as a service, for BC, we can simply call to the new service from the static methods?
This would also make it easier to override that API. The original mailsystem maintainer for example tried for years to get a core patch with improvements committed but didn't succeed. This would allow us to replace the service for now.
Comment #15
jungle