Incorrect content url generated for !url
whiteb - April 21, 2008 - 19:28
| Project: | Auto Expire |
| Version: | 5.x-1.0 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | marcvangend |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
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.

#1
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.