Posted by justintime on December 14, 2009 at 8:26pm
Jump to:
| Project: | Node Gallery |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
The per-user bytes quota is checked via Drupal's file_validate_size() function. This function looks at the user's total bytes used throughout the Drupal installation (as represented in the files table). The problem is that if a site implementing Node Gallery is using the Upload module (or any other module that tracks files in the files table), those files will be counted against the user's quota, even though they are not a Node Gallery image type.
My best guess at a fix is to write our own validator that sums up only the correct files in the files table.
Comments
#1
It might be too intensive to write that (because of the extra processing against the database + having to "reinvent the wheel."
Ideally, the nodegally will leverage imagefield in 3.x, so it may not be worth spending the time to solve this issue for 2.x?
#2
That's what I was hoping you'd say ;-)
I'll mark this one as postponed, but do we have a "Known Issues" area where we can keep track of things like this? I hate to turn off the whole feature, as it may prove useful to a lot of people, there's just a bug associated with it.
#3
yes there is 2 places for known issues.. one on the project page and
http://drupal.org/node/544050 ,the handbook main page
It could be detailed in the troubleshooting section of the handbook.. use php my admin to edit the files table(remove failed uploads) -or- set the limits high to avoid this altogether.
Is there some idea of a time frame for Node_gallery 3x.. possibly.?
I guess I am assuming node_gallery3x will be for D7..?
#4
Wouldn't something like this work?
<?php
function _ng_file_validate_size($file, $file_limit = 0, $user_limit = 0) {
global $user;
$errors = array();
// Bypass validation for uid = 1.
if ($user->uid != 1) {
if ($file_limit && $file->filesize > $file_limit) {
$errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' =>
format_size($file->filesize), '%maxsize' => format_size($file_limit)));
}
// Save a query by only calling file_space_used() when a limit is provided.
if ($user_limit && (_ng_file_space_used($user->uid) + $file->filesize) > $user_limit) {
$errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' =>
format_size($file->filesize), '%quota' => format_size($user_limit)));
}
}
return $errors;
}
function _ng_file_space_used($uid = NULL) {
if (isset($uid)) {
return (int) db_result(db_query("SELECT SUM(f.filesize) FROM {files} f JOIN {node_galleries} ng ON ng.fid = f.fid WHERE f.uid = %d", $uid));
}
return (int) db_result(db_query('SELECT SUM(f.filesize) FROM {files} f JOIN {node_galleries} ng ON ng.fid = f.fid'));
}
?>
#5
I would support marking this as "won't fix" for 2.x
#6
Kicking up to NG3 to see if this issue is sill relevant. If not I suggest following #5.
#7
Marking as won't fix for 2.x, it's not an issue in 3.x. In 3.x, we don't have an option to limit on total size. You can achieve similar results by setting a max size on imagefield, and then using node_limit or another similar module.