-
Notifications
You must be signed in to change notification settings - Fork 823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Provide hook for updating absoluteBaseURL #10168
Conversation
It feels wrong adding the same hook/extension point in three different places. Can it be consolidated into one? |
I didn't want to change too much of the structure of The only clean ways to consolidate them that I can think of are:
Out of the above I prefer 2 since it means calls to @michalkleiner Let me know if either of the above appeal to you, or if you can think of some alternative that hasn't occurred to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this PR seems a bit wrong in its current state. We certainly should not have the same hook in 3 different places.
I'm not sure why the 2 hooks in absoluteUrl() are there?
absoluteBaseURL() calls absoluteUrl(), meaning the hook would get called twice? (once in absoluteUrl(), then a second time in absoluteBaseURL())
Seems like we should retain the changes in absoluteBaseURL() and revert the absoluteUrl()?
Ultimately, if a developer wants to convert a relative URL to an absolute URL, they will call If a developer want just the absolute base URL, it should be likewise updated - but as you correctly pointed out this ultimately will call I think that having looked at this with fresh eyes the best way to do this is to put a single hook after the silverstripe-framework/src/Control/Director.php Lines 453 to 472 in f9cceef
If @emteknetnz and @michalkleiner are happy with this approach, I'll make the change. Edit: We'll probably need one before line 456 as well - or else refactor the way/timing of that return statement to avoid duplicate hook calls. |
Yes, just adding a single extension hook inside I don't think we need to do anything with the line 456 since that's for external linls |
One use case for this that I've run into a few times is for sending emails using a queued job from the CLI.
4960e8c
to
0c561ce
Compare
@emteknetnz I've made the change. That's much nicer, I'm glad you didn't like my first approach 😁 |
This PR ended up indirectly causing a lot of regressions - I've created a PR to revert it #10291 |
…stripe#10168) One use case for this that I've run into a few times is for sending emails using a queued job from the CLI.
One use case for this that I've run into a few times is for sending emails using a queued job from the CLI.
Calling
setBody
on an email usesDirector::absoluteURL
which ultimately usesDirector::baseURL
to make email links absolute. This can often result in the host being the server name rather than the actual website host name.Providing this as an extension makes it easy to configure for a variety of possible situations that could result in needing dynamic control of the absolute base URL - such as using subsites.