Download & Extend

Incorrect content url generated for !url

Project:Auto Expire
Version:6.x-1.0-rc1
Component:Code
Category:support request
Priority:normal
Assigned:marcvangend
Status:active

Issue Summary

I am using drupal 5.7 and 5.x-1.0 of auto expire. I have clean URLs turned on. I received an email with an expiration notice for a node, but the URL was malformed. It left the actual site address out. The exact form received was: http:///node/86

What could cause that?

I set this up in a test environment before loading it into production and it worked fine, but I had a slightly different version of Drupal (5.4) and no clean urls.

Comments

#1

Assigned to:Anonymous» marcvangend
Status:active» postponed (maintainer needs more info)

Brad, I know this issue has remained unanswered for a long time, sorry about that. Have you ever discovered the cause of this error? I'm trying to figure out if we still have to look into this, or if this issue can be closed.

#2

I see this incorrect behavior on D6.0 using Auto Expire 6.x-1.0-rc1. The offending code fragment appears to be in:

function _auto_expire_notify_warning($nid, $title, $type, $days, $subject, $body $args = array(
'!type' => $type,
'!title' => $title,
'!url' => url('node/'. $nid, array('absolute' => TRUE)),
'!days' => $days,
'!date' => format_date(_auto_expire_get_expire($nid)),
'!daysleft' => format_interval(_auto_expire_get_expire($nid) - time()),
'!site' => variable_get('site_name', ''),
'!siteurl' => url('', array('absolute' => TRUE)),
);

But I don't know how to fix it.

#3

Jon, thanks for your bug report.
The url() function is used correctly in that chunk of code (see http://api.drupal.org/api/function/url/6) so I'm wondering if it has anything to do with your site configuration (like it was in #243468: Reminder email links don't have the site's domain). Can you check your settings.php to see if the $base_url variable has been set? If set, make sure it is correct. If not set, then set it and see if that solves the problem.

#4

marcvangend, thanks for your quick support!

I made the change to $base_url as you suggested.

Because I didn't expect such a fast response, I did some digging and came up with the API (I probably shouldn't be there). But according to http://api.drupal.org/api/function/url/6 , shouldn't 'external' => TRUE be defined to guarantee an external url. Please pardon my ignorance, but I just don't know.

Thanks again,
Jon

#5

Jon, if you like to know more about the internals of Drupal, you're definitely invited to the API documentation.

The 'external' option is meant to create url's that are outside the current Drupal installation. For instance, compare these two lines of code:

<?php
return url('http://www.google.com/search', array('query' => 'q=drupal', 'external' => TRUE));
// Returns "http://www.google.com/search?q=drupal", this is an external url

return url('http://www.google.com/search', array('query' => 'q=drupal', 'external' => FALSE));
// Returns "/http%3A/%252Fwww.google.com/search?q=drupal" because 'http://www.google.com/search' is interpreted as a Drupal path instead of [protocol]://[domain]/[path]
?>

Since Auto Expire is generating a url inside it's own Drupal installation, 'external' is not applicable here. However the 'absolute' option is TRUE, because we want Drupal to include http:// and the base url so it will also work when clicked from an email.

Anyway: you say you changed the $base_url variable, but does it actually work?

#6

Thanks for the explanation.

I won't know until 11/04/2009 if the change worked. That's when the next piece of content is set to expire. Is there a way to test it?

#7

Are you using the devel module? If you do, enable the 'Execute PHP' block, enter print url('node', array('absolute' => TRUE)) and click the 'execute' button. If all is well, you will see the correct url to the /node page printed in the messages area on your page.

#8

I'm not using the devel module (yet), but I had one come through this morning that appears to work. I had replaced !url with !siteurl, but I received a valid link to the site, so unless it reverts, thank you.

#9

I'm using Auto Expire 6.x-1.0-rc1, some strange behavior appear on the '!url' and '!siteurl' field when email received, sent out using the default auto expire email message, both appears as follow, it doesn't convert my base url properly:

!siteurl:
http://default/home/my_folder/html/mydomain.com/public/scripts/

!url
http://default/home/my_folder/html/mydomain.com/public/scripts/path/to/node

However, when I added a trailing space immediately after both '!url' and '!siteurl' into the auto expire email message that's going to send out:

!siteurl(space)
!url(space)

both url in the email message received appears to convert my base url properly, except this time it becomes http'S' instead of http (I have ssl enabled):

!siteurl:
httpS://www.mydomain.com/

!url:
httpS://www.mydomain.com/path/to/node

Does anyone have any comment on this? Why is it behave so?

#10

One reason people are getting weird output is because variable_get in the module has no default set for site_name, the correct way to retrieve the variable is to use;

<?php
variable_get
('site_name', 'Drupal');
?>

Else Drupal does tend to get a bit confused.

I will address this (and other issues) when I get home from work tonight on http://drupal.org/node/313280.

Pobster

#11

Version:5.x-1.0» 6.x-1.0-rc1
Component:Miscellaneous» Code
Status:postponed (maintainer needs more info)» active

I am using Auto Expire 6.x-1.0-rc1 with the Expiration Warning Notification Email template as follows:

Your !type listing '!title' will expire in !daysleft.

Please visit the Example website if you want to extend your !type listing:
!url

The Email body sent out has 'http://default/node/25' instead of 'http://www.example.com/node/25' in the message body.
Your Notice listing 'Test Title' will expire in 4 days 13 hours.

Please visit the Example website if you want to extend your Notice:
http://default/node/25

Everything else is working fine.

Thank you very much for the otherwise great working module.