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

Alexander Ufimtsev - March 24, 2009 - 22:14
Project:Bibliography Module
Version:5.x-1.16
Component:Code
Category:bug report
Priority:normal
Assigned:Alexander Ufimtsev
Status:closed
Description

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

#1

rjerome - March 25, 2009 - 01:11

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

Alexander Ufimtsev - March 25, 2009 - 22:21

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

rjerome - March 26, 2009 - 01:28

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

rjerome - March 26, 2009 - 01:29
Status:needs review» fixed

#5

System Message - April 9, 2009 - 01:30
Status:fixed» closed

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

#6

Alexander Ufimtsev - July 29, 2009 - 13:31

Hi Ron,

Any chance of a release any time soon?

A

#7

rjerome - July 29, 2009 - 14:26
Status:closed» active

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

#8

rjerome - July 29, 2009 - 19:41

The new release is out now.

Ron.

#9

Alexander Ufimtsev - August 4, 2009 - 19:20
Status:active» fixed

cheers! works perfectly!

#10

System Message - August 18, 2009 - 19:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.