I've noticed a few issues with the field length of the text fields in project_release nodes (on the edit form).
These lengths are set in either the project_release_form() function when calling _project_release_form_add_text_element()or set by default in the _project_release_form_add_text_element() declaration itself.
The 5 fields that are processed by _project_release_form_add_text_element() are:
- Title
- Version string
- File path
- File MD5 hash
- File Date
Of those 5 fields, the MD5 hash length and the file date fields are fixed length, and are not a problem.
The other 3 fields have these length limitations (as set in either the call or declaration of _project_release_form_add_text_element():
- Title
- 40 (hard coded in call to function)
- Version String
- 20 (hard coded in call to function)
- File path
- 40 (default from function declaration)
The length of the corresponding database fields are as follows:
- Title
- 128 (node.title field)
- Version String
- 255 (project_release_nodes.version field)
- File path
- 255 (project_release_nodes.file_path field)
Is there a reason that we're setting the field lengths to be a lot shorter than they can/should be?
This is causing problems on my site, because some of my file_paths have lengths that are >40 chars, and so you can create the release and upload the file the first time, but then when you try to edit the release node and submit, you get errors from the filesize() function call in project_release.module because the truncated file_path is not a valid file.
As I see it, we can fix this in 2 ways:
1. Hard code the size of the database fields for each of these as the maximum size of the text field.
2. Add a few strlen() calls in the calls to the _project_release_form_add_text_element() function or alternately in that function itself, where it might override the passed/default value of $size if strlen($value) > $size.
I can make a patch to fix this either way, but I was wondering what you would prefer.
I'm marking this critical because it produces a error message within drupal, and also messes up the file_path values and presumably version string and title fields, if those are also too long.
AC
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | project_release_field_lengths.txt | 2.65 KB | aclight |
Comments
Comment #1
dwwi'd prefer to just have the form's display width (#size) be as it currently exists, and the max width (#maxwidth) be the existing sizes of the DB columns. that should solve everything you care about, no? should be a trivial patch.
thanks,
-derek
Comment #2
aclight commentedOk. see attached.
AC
Comment #3
dwwperfect, thanks! reviewed, tested and committed to HEAD and DRUPAL-4-7--2 (the only branches where project_release.module exists). on futher thought, you're right, this was a critical bug.
p.s. greetings from the O'Hare Crowne Plaza hotel. ;) i'm here for the weekend for http://socialismconference.org if you care to meet up...
Comment #4
(not verified) commented