Closed (fixed)
Project:
Download Count
Version:
4.7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
5 Mar 2007 at 02:04 UTC
Updated:
20 Mar 2007 at 20:46 UTC
Jump to comment: Most recent file
when you upload two files with the same file name, upload module gives them different names on file system, but the filename field in table files stayes the same for both files.
in the other hand, filename field of file_downloads table contains file name as it is on the file system.
in the described situation, your code $result = db_query("SELECT fd.filename, fd.count, fd.timestamp, f.nid, n.type FROM {file_downloads} fd JOIN {files} f ON fd.filename = f.filename JOIN {node} n ON n.nid = f.nid" . tablesort_sql($header)); will not fetch those files, thus, they won't be displayed on download_counter page.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | download_count_0.patch | 1.21 KB | darko.ilic |
| #1 | download_count.patch | 1.2 KB | darko.ilic |
Comments
Comment #1
darko.ilic commentedworks for me...
Comment #2
darko.ilic commentedI forgot
LIKEis case in-sensitive by defaultplease ignore my previous patch, here's the one that works
Comment #3
Chill35 commentedGreat catch. And great fix. I looked at your code and I am impressed. Your knowledge of mysql surpassses mine.
The filename that is recorded in {file_downloads} is indeed the actual file name. Not the filename (a.k.a file description) that appears to users in the node.
$result = db_query("SELECT fd.filename, fd.count, fd.timestamp, f.nid, n.type FROM {file_downloads} fd JOIN {files} f ON BINARY fd.filename LIKE SUBSTRING(f.filepath FROM 7) JOIN {node} n ON n.nid = f.nid" . tablesort_sql($header));I will test this quickly and apply the patch.
Note to you & everyone : if you look at the download_count.install, I am just not doing anything for a pgsql database. Do you know what the pgsql syntax would be for LIKE SUBSTRING(f.filepath FROM 7)... would it be the same ? Is the database creation the same, also, for a pgsql database ?
Thanks a million!
Comment #4
darko.ilic commentedthank _you_ for the module, it was quite helpful :)
see ya
Comment #5
Chill35 commentedI also had to modify theme_download_count_body($node), darko.
I also fixed the Drupal 5.x version.
I used a slightly different approach because the
SUBSTRING(f.filepath FROM 7)did not work in all scenarios. I used CONCAT with the File System Path.Here's the solution I used:
Etc.
Thanks again! Let me know if we'll run into case-sensitive glitches with that fix.
The fix is now in CVS and new versions will be built within the next 24 hours.
Comment #6
Chill35 commentedI surfed the MySQL doc, but didn't find what I was looking for, i.e. the equivalent of the php function strstr. I wanted to use something like: WHERE the filename is a substring of filepath... Maybe I had to use something like SUBSTRING(f.filepath FROM -COUNT(fd.filename)).
Comment #7
(not verified) commented