Hello,
We are using this module in multiple environments.
Each of those environments are either installed through virtual hosts or installed in subdirectories.
We are encountering problems with environments in subdirectories.
First part of the problem
This is the body of my node:
Hello,
I'm just the body of a node, I'm just here for demonstration purpose.
Here is a <a href='subdirectory/node/1'>link</a>, I hope you'll made good use of it.
When it goes to the function simplenews_statistics_mail_alter(), the function _simplenews_statistics_absolute() is called.
This will transform all relatives (and pseudo relatives) links into absolutes.
Our body become:
Hello,
I'm just the body of a node, I'm just here for demonstration purpose.
Here is a <a href='http://www.example.com/subdirectory/subdirectory/node/1'>link</a>, I hope you'll made good use of it.
As you can see the subdirectory is now twice in the url, which leads to a 404.
Second part of the problem
If you use different languages...
This is the body of my node:
Hello,
I'm just the body of a node, I'm just here for demonstration purpose.
Here is a <a href='fr/node/1'>link</a>, I hope you'll made good use of it.
When it goes to the function simplenews_statistics_mail_alter(), the function _simplenews_statistics_absolute() is called.
This will transform all relatives (and pseudo relatives) links into absolutes.
Our body become:
Hello,
I'm just the body of a node, I'm just here for demonstration purpose.
Here is a <a href='http://www.example.com/fr/fr/node/1'>link</a>, I hope you'll made good use of it.
Why ?
Look at the function _simplenews_statistics_absolute(), at line 157, the function url() doesn't take in account the language parameter, it means that when you ask Drupal to return the url of the frontpage, it will add the default language at the end of it, which can cause problems in that case.
We can solve a part of the problem using
url('<front>', array('absolute' => TRUE, 'language' => LANGUAGE_NONE))
but I don't know if it's a valid solution (having in mind the first part of the problem)
What do you think ? I hope we'll find a solution before the stable release!
Comments
Comment #1
weseze commentedSetting to 7.x.
I think that we could even skip the relative to absolute conversion completely. Since all links should become encrypted/shortened anyway you could keep relative paths.
"fr/node/1" would be converted to "http://www.example.com/thQp" when the newsletter is sent. Drupal would then respond to the 'thQp" part and issue a drupal_goto() to "fr/node/1", wich I believe would work just as expected.
Comment #2
weseze commentedRelative to absolute conversion was removed in latest commit.