See line 865: $output = ' <dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>';

This will print out the link like 'http://base_url/my/full/unix/path/to/sites/default/files/my_file'

Need to figure out unix path up to file path, and then substr from there.

I hacked it in for a specific site like $item['link'] = substr($item['link'],'/my/full/unix/path/to/');, but this does not solve the issue well.

Comments

cmgui’s picture

I also have the same problem. I am using Private File System. Uploaded files go to /usr/files/.
Drupal resides in /usr/local/www/drupal/.

Search Files works but the download link does not work.
The link shows up as http://test.example.com/usr/files/filename.pdf

The correct URL should be http://test.example.com/system/files/filename.pdf
since i have configured my drupal to use the private file system.

This is how I 'fixed' it.
added this line after line 819 in search_files.module
// added this for private file system
$link = str_replace("/usr/files","/system/files",$link);

Works but this isn't good because it assumes i will be using Private File System forever.

Also, if Drupal is not installed on the root and is installed on a subfolder, i.e.,
http://test.example.com/drupal/ , Search Files links also fail to have the 'drupal' in the URL.

Thank you.

miruoss’s picture

I think you speak of different things. However, I had the same problem as mradcliffe. The way the links are created on the search result page is pretty ugly. I wonder why they didn't use the function l() provided by drupal to create links.

First of all the assumption on line 809 to have a leading slash in the link is wrong. The following code of lines 809 through 814 should be removed:

          // we have had a problem where some links were returned relative to the search page,
          // not the document root, basically there was no beginning forward slash '/' in the
          // path
          if (strpos($link, '/') !== 0) {
            $link = '/'. $link;
          }

Furthermore the code mentioned by mradcliffe should be changed into:

  $output = ' <dt class="title">'. l($item['title'], $item['link']) .'</dt>';

btw: check_plain() and check_url() are no longer needed as they are done by l().
and: this does not handle the special case mentioned by cmgui