Download & Extend

Download link not relative to Drupal root

Project:backup
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:dmuth
Status:closed (fixed)

Issue Summary

I have a Drupal installation sandbox, but not on its own domain (http://sandbox.com/drupal/). When I make a backup I get the normal message list:

  • Database backed up successfully.
  • Files backed up successfully.
  • Click this filename to download: drupal-backup-20070426035619-842029818.tar.gz

However, the link does not point to the file. The path should be (if no directory is given):

http://sandbox.com/drupal/drupal-backup-20070426035619-842029818.tar.gz

But I get this instead:

http://sandbox.com/drupal-backup-20070426035619-842029818.tar.gz

It shows up on the list of backups fine. I tracked this down to line 205 of backup.module.

204  $message = t("Click this filename to download: ")
205  . "<a href=\"/". $backup_file . "\">" . $backup_file . "</a>";
206  watchdog("backup", $message);
207  drupal_set_message($message);

I put in the path of my installation and it worked fine:

205  . "<a href=\"/drupal/". $backup_file . "\">" . $backup_file . "</a>";

Again, this is only for the initial message with the link. The list of files below it all have the correct paths. Also, I tested it with a directory chosen for the backup location with the same results.

It really pains me to bring this up, but honestly I know jack about PHP, and I don't know how to put the directory in. I looked at the array you use in forms.inc.php, but I don't know how to pop that in the module.

It isn't a large problem, but since you are making it for non-techies, and someone may put up an installation that is not at the root with the domain, it is worth figuring out.

Thanks for the great module, and I hope I learn something from this.

maiki

Comments

#1

Priority:minor» normal
Assigned to:Anonymous» dmuth

Whoa! Thanks for catching that. That's what I get for running Drupal out of the webserver's root directory. :-)

I think your fix will work just fine. I will look into coding a more permanant fix for the problem. Thanks for bringing that to my attention.

-- Doug

#2

Status:active» reviewed & tested by the community

The fix is actually really simple: instead of printing the HTML anchor tag directly, ask Drupal to do it via the l() function, so it's printed correctly, relatively to the site root.

I'm attaching a patch I just made against backup 5.x-2.x-dev (last update to the module version was on March 28, 2007 - 03:04).

Hope it helps.

AttachmentSize
correct_url_in_message.patch 454 bytes

#3

Status:reviewed & tested by the community» fixed

I have implemented your patch, thank you for providing it!

Details on the upcoming release can be found at http://drupal.org/node/151077

-- Doug

#4

Status:fixed» closed (fixed)
nobody click here