Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
path.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Jan 2008 at 17:43 UTC
Updated:
16 Feb 2008 at 21:42 UTC
Jump to comment: Most recent file
Comments
Comment #1
c960657 commentedComment #2
webchickPlease don't set your own patches ready to be committed. All patches need community review, and *especially* when they're touching a function that's used basically everywhere.
Could you clarify what we need to do to test this?
Comment #3
c960657 commentedSorry, I chose the "ready to be committed" by mistake.
For testing purposes, you can add the following function to settings.php. It directs all requests to /admin to www1.yoursite.example.com, while the rest is served by www2.yoursite.example.com. Both hostnames should point to the same server, and the site should reside in sites/yoursite.example.com.
Comment #4
moshe weitzman commentedthis would be very useful for serving static content from a different domain like files.example.com, for example.
Comment #5
agentrickardI have use-cases for this as well, over in the Domain Access module.
In some cases, I need to force $absolute values to be attached to URLs -- for example, when searching content from multiple domains, the links need to go to sites where access rules allow the nodes to be viewed.
In 5.x, I had provided a hook_url_alter() patch to provide this functionality, and have tried to backport custom_url_rewrite_outbound() since learning of the function.
http://drupal.org/node/210248
However, custom_url_rewrite_outbound() fires too late in the url() function for me to make any modification to the $options['absolute'] parameter.
This patch addresses that need, however, I think it introduces the potential to leave $base unset if the IF check for (!empty($path) && $path != '') returns FALSE.
Perhaps we should move the custom_url_rewrite_outbound() sequence instead?
For reference, my approach was to run the rewrite hook at the very top of the url() function.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/domain/patc...
Comment #6
c960657 commentedI don't see which code path leads to $base being unset? That is, not unless the custom_url_rewrite_outbound() function calls unset($options['base_url']) or similar, but that would be bad behaviour by the custom_url_rewrite_outbound(), wouldn't it?
However, it probably is a good idea to move the custom_url_rewrite_outbound(). The current implementation doesn't support rewriting URLs to the site root (i.e. when $path == ''). This updated patch fixes this.
BTW, see also a related issue regarding rewriting URLs to uploaded files: http://drupal.org/node/207310
Comment #7
agentrickardWith regard to $base, I may have read the code incorrectly.
I like this new patch, since it is exactly what I was going to propose.
Comment #8
agentrickardThe patch works, and you can rewrite $options['base_url'] and set $options['absolute'] = TRUE in order to force links to go to different hosts. It also preserves url aliases.
There are, of course, performance implications, but that is a trade-off for added functionality for sites that choose to implement the function. I have not done extensive performance testing.
Marking RTBC because I'd like to get input from core committers.
Comment #9
gábor hojtsyThis is an API change for the custom rewriter too late for 6.x.
Comment #10
c960657 commentedFWIW, with this patch applied the API still adheres to the documentation at http://api.drupal.org/api/function/custom_url_rewrite_outbound/6.
The documentation does not indicate that only certain values in $options can be changed, so one could argue that this is not an API change but a bugfix.
Comment #11
agentrickardThe argument is that this is a bugfix, since the original feature did not consider all use cases.
I will reset this issue once. If it is rejected as too late in the release cycle, then I accept that it is a feature for 7.x.
If it does not go in to 6.x, I will be releasing this patch (or something like it) as part of the Domain Access module.
Comment #12
gábor hojtsyWell, the patch is also an API change in that it removes the possibility to modify $options['prefix'], although it is supposed to be modifiable from the function. Let's try to not break APIs when you are advocating a patch as a bug fix. :)
Comment #13
c960657 commentedSorry, that was not intended. Here is another try that retains the ability to alter $options['prefix'].
I reversed the if statement, now that the else part is only relevant when $path == '<front>'.
I assume that the purpose of
trim($options['prefix'], '/')is to remove the trailing slash, so I changed it to rtrim() to make this clearer. I hope this makes sense.Comment #14
moshe weitzman commentedworks perfectly. the only thing i did not test is interaction with locale. hopefully gabor can verify that.
here is the function i used to test (note base url change at bottom). i will change the docs accordingly once this goes in.
Comment #15
gábor hojtsyWell, this patch also fixes URL encoding of the path prefix when we are on the front page, which makes it all consistent with the path handler case, so committed, thanks.
Comment #16
agentrickardAttached is a backport for Drupal 5, if anyone needs it.
Comment #17
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.