Download & Extend

Broken download links when filtering with clean URLs (e.g. /biblio/year/2009)

Project:Bibliography Module
Version:5.x-1.16
Component:Code
Category:bug report
Priority:normal
Assigned:Alexander Ufimtsev
Status:closed (fixed)

Issue Summary

When clean URLs are enabled on filtering, e.g. /biblio/author/Smith or /biblio/year/2009, download links for papers become incorrect, pointing to /biblio/author/Smith/files/file.pdf instead of /files/file.pdf. The following patch fixes the problem:

Index: biblio.module
===================================================================
--- biblio.module       (revision 226)
+++ biblio.module       (working copy)
@@ -2051,7 +2051,7 @@
       $output .= '   '. t('Download') .': ';
       $output .= '<span class="biblio_export_links">';
       foreach ($node->files as $file) {
-        $output .= '&nbsp;<a href="' . $file->filepath . '">' . $file->filename . '</a>&nbsp;';
+        $output .= '&nbsp;<a href="' . file_create_url($file->filepath) . '">' . $file->filename . '</a>&nbsp;';
       }
       $output .= '</span>';
     }

Please review.

AttachmentSize
fix-biblio-download.patch596 bytes

Comments

#1

Thanks for pointing that out, I'm surprised no one ran into this before.

I did something a little different than you suggested, I used the l() function instead like this...

$output .= '&nbsp;'. l($file->filename, $file->filepath). '&nbsp;';

Ron.

#2

Yes, l() seems to be more elegant, though both of l() and file_create_url() end up calling url() at the end of the day anyway. I'm also surprised that out of almost 300 installations we were the first to spot this bug.

Thank you, Ron!

Alexander

#3

FYI, I'm going to roll a new 5.x release later this week which will contain this fix as well as a few enhancements (some new styles: AMA, Chicago, MLA and Vancouver)

Ron.

#4

Status:needs review» fixed

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#6

Hi Ron,

Any chance of a release any time soon?

A

#7

Status:closed (fixed)» active

Oops, this one completely slipped my mind (and since it was automatically closed) it slipped off the radar screen, sorry about that.

#8

The new release is out now.

Ron.

#9

Status:active» fixed

cheers! works perfectly!

#10

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.