function _private_upload_migrate_private()

reports following problem...

user warning: Unknown column 'f.nid' in 'where clause' query: SELECT f.* FROM files f, node_access na WHERE f.nid = na.nid AND na.gid != 0 AND f.filepath NOT REGEXP "^uploads/private" GROUP BY f.fid in /users/home/progfrog/domains/photoremake.com/web/public/sites/all/modules/private_upload/private_upload.module on line 586.

... on the admin/user page.

The private upload configuration page at admin/settings/private_upload
reported: "There are 3 public files attached to private nodes. Click here to make them all private."

I clicked on the link, but the migration never went through. Instead the above error turned up.

I am not familiar with the code, but apparently there is no nid field in the file table; nid field that is used in the where clause.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jvieille’s picture

Probably the same problem for me, though somewhat different behaviour

I went to enabling Private Upload after installing this module for the first time while upgrading to D6.6
The process went successfully

I was happy seing several green notices and reading the following:
"There are 98 public files attached to private nodes. Click here to make them all private."

I clicked but only got a white page (no warning at this time). Nothing changed on the server, the files/private directory contains only 2 iles ".htaccess" and "privacy_test.txt"
Going back to the admin/settings/private_upload page, I got this warning:

"user warning: Unknown column 'f.nid' in 'where clause' query: SELECT f.* FROM files f, node_access na WHERE f.nid = na.nid AND na.gid != 0 AND f.filepath NOT REGEXP "^sites/default/files/private" GROUP BY f.fid in /home/psynapse/public_html/controlchaingroup/sites/all/modules/private_upload-6.x-1.0-rc2/private_upload/private_upload.module on line 586."

Refreshing the page makes the warning wanished

Hope this helps

rimu’s picture

Title: Migrate function fails with poor error info due to incorrect query - patch attached, also adds watchdog support » Private upload migrate problem.
Status: Needs work » Active

around line 585, in the function called _private_upload_migrate_private, change this

  $result = db_query('SELECT f.* FROM {files} f, {node_access} na '.
                     ' WHERE f.nid = na.nid AND na.gid != 0 AND f.filepath NOT REGEXP "^%s" '.
                     ' GROUP BY f.fid', $private_path  );

to this

  $result = db_query('SELECT f.* FROM {files} f inner join {upload} u on f.fid = u.fid INNER JOIN {node_access} na ON u.nid = na.nid '.
                     ' WHERE na.gid != 0 AND f.filepath NOT REGEXP "^%s" '.
                     ' GROUP BY f.fid', $private_path  );
alexharries’s picture

Title: Private upload migrate problem. » Migrate function fails with poor error info due to incorrect query - patch attached, also adds watchdog support
Status: Active » Patch (to be ported)
FileSize
4.36 KB

** EEP: don't apply this patch - I haven't tested it fully - see my next post instead please! **

Attached is a patch which should hopefully fix this issue (see http://drupal.org/patch/apply to find out how to apply this patch to an existing install, if you want to try it, but I wouldn't recommend using this on a live system! ;o).

/al

ñull’s picture

Status: Patch (to be ported) » Needs work

I applied the patch and run the migration and got this error:

Parse error: syntax error, unexpected ')' in mypath/modules/private_upload/private_upload.module on line 645

After removing the unexpected ')', I got the following message:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'current_timestamp, n.title node_title, ncv.vid current_vid, ucv.fid curren' at line 6 query: SELECT f.*, na.*, u.*, r.timestamp old_timestamp, n.changed current_timestamp, n.title node_title, ncv.vid current_vid, ucv.fid current_fid FROM files f INNER JOIN upload u ON (f.fid = u.fid) LEFT JOIN upload ucv ON (ucv.nid = u.nid AND ucv.vid = (SELECT MAX(n2.vid) FROM node n2 WHERE n2.nid = ncv.nid)) INNER JOIN node_revisions r ON (r.vid = u.vid) INNER JOIN node_access na ON (u.nid = na.nid) INNER JOIN node n ON (n.nid = na.nid AND n.vid = u.vid) INNER JOIN node ncv ON (ncv.nid = u.nid AND ncv.vid = (SELECT MAX(n2.vid) FROM node n2 WHERE n2.nid = ncv.nid)) WHERE na.gid != 0 AND f.filepath NOT REGEXP "^mypath/files/private" GROUP BY f.fid in mypath/modules/private_upload/private_upload.module on line 612.
Lloyd’s picture

Any update on this. I'm also getting a white screen when trying to migrate the public files attached to private nodes.

span’s picture

Me too actually, anyone with a clue?

jvieille’s picture

I abandoned Drupal core file handling for File Framework.
This module offers total privacy and extensive flexibility in file management.

caw67’s picture

Title: Private upload migrate problem. » Migrate function fails with poor error info due to incorrect query - patch attached, also adds watchdog support
Status: Active » Needs work

the patches are not in the new version!

jromine’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
FileSize
877 bytes

Confirm the change in #2 by rimu works. Current patch file attached.