[drupal-devel] [bug] upload.module bug preventing file download
Issue status update for http://drupal.org/node/22723 Project: Drupal Version: 4.6.0 Component: upload.module Category: bug reports Priority: critical Assigned to: Anonymous Reported by: ejort Updated by: ejort Status: patch Attachment: http://drupal.org/files/issues/upload.module.from_FROM.patch (910 bytes) Hi, I've just released a new site which has nodes only accessible by authenticated users. These nodes also have attached files via upload.module. I struck a problem where users were unable to download these files due to a bug in upload.module, instead they received 'page not found', with the following error output: "user error: Unknown table 'na' in where clause query: SELECT DISTINCT(f.nid), f.* from cms_files f WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','term_access2','term_access6')) AND filepath = 'files/20050307_minutes.doc' in /srv/www/htdocs/docs_renegades/www/includes/database.mysql.inc on line 66. " The problem was that the node_db_rewrite_sql() WHERE statement was being inserted, but not the corresponding JOIN statement (where 'na' is declared as an alias of {node_access}). Looking through the code it seems this is because the regex in the db_rewrite_sql() function is looking for 'FROM' (all caps), whereas the upload.module query sent to db_rewrite_sql has 'from' (lower case). Changing from -> FROM fixes the problem. This patch should apply to 4.6.0 and cvs, though I didn't look to see if the cvs version of db_rewrite_sql() still looks for an uppercase FROM. Cheers, Eric ejort
Issue status update for http://drupal.org/node/22723 Project: Drupal Version: 4.6.0 Component: upload.module Category: bug reports Priority: critical Assigned to: Anonymous Reported by: ejort Updated by: ec Status: patch You folk, you save my day. I found this bug yesterday while I was using OG see here http://drupal.org/node/22664. I test your patch and it solves my problem, many many thanks. Hope this will be committed soon. I will also post to OG. Regards, Eric ec Previous comments: ------------------------------------------------------------------------ May 13, 2005 - 05:16 : ejort Attachment: http://drupal.org/files/issues/upload.module.from_FROM.patch (910 bytes) Hi, I've just released a new site which has nodes only accessible by authenticated users. These nodes also have attached files via upload.module. I struck a problem where users were unable to download these files due to a bug in upload.module, instead they received 'page not found', with the following error output: "user error: Unknown table 'na' in where clause query: SELECT DISTINCT(f.nid), f.* from cms_files f WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','term_access2','term_access6')) AND filepath = 'files/20050307_minutes.doc' in /srv/www/htdocs/docs_renegades/www/includes/database.mysql.inc on line 66. " The problem was that the node_db_rewrite_sql() WHERE statement was being inserted, but not the corresponding JOIN statement (where 'na' is declared as an alias of {node_access}). Looking through the code it seems this is because the regex in the db_rewrite_sql() function is looking for 'FROM' (all caps), whereas the upload.module query sent to db_rewrite_sql has 'from' (lower case). Changing from -> FROM fixes the problem. This patch should apply to 4.6.0 and cvs, though I didn't look to see if the cvs version of db_rewrite_sql() still looks for an uppercase FROM. Cheers, Eric
participants (2)
-
ec -
ejort