well, in the process of fixing file previews for new issues, another problem has been created.

the attached file is now associated directly w/ the user session, so if you upload a file in a preview, then decide against attaching it, it's stuck in your session, and you carry it around to any other issue or issue comment as an already uploaded file.

this could result in a file accidentally getting uploaded. at this point the only way to evacuate the preview file is to either upload another to replace it, or log out and back in so you have a fresh session.

this problem has probably always been around in some lesser form, but is now exacerbated by the fact that file previews in issue followups are no longer associated w/ the issue node itself.

not sure how best to handle this. even if we re-associate the file previews for issue followups to the node of the issue, it still doesn't completely fix the problem. not to mention that i see no reliable way to associate a file upload with a new issue creation -- it would be carried to any other new issue creation.

my best plan atm is:

  1. change the logic back for issue folowups so that files are associated with the issue node. this will at least fix any cross issue errors.
  2. either advise users who have a file stuck from previewing to log out and back in, or...
  3. add a 'Remove file' button when a file has been uploaded in preview.

or maybe there's some way to associate the file in the user session subject to the actual form instance you're on, but i'm not seeing it...

Comments

dww’s picture

I don't know exactly what changed that caused files to be associated with user sessions instead of issues in the first place. But, from the description of this issue, your plan mostly seems fine. I think i'd rather see a "remove file" button than a warning "if you don't want to upload that file, please log out and log back in" -- that seems like an utter hack and usability disaster. ;) the "remove file" button could also be a good way to garbage collect stale files that were uploaded but not actually attached, right?

hunmonk’s picture

issue followup files were previously stored in $node->file. to keep the code simple, they were moved to the user session (where the initial issue files are now kept). now of course i see that as a dumb move, b/c of the problem we're having :)

i also vote for the remove file button, even though it will be a bit more work.

hunmonk’s picture

after further investigation:

  1. this problem had existed even before my recent patch to fix file preview on new issue creations. basically, on either new issues or followups, the uploaded file is stuffed in 'file_issue' in the session. for some reason, project_issue_comment_validate(&$node) is called even when a brand new followup is loaded, and that function loads whatever is in 'file_issue' into $node->file. basically, even before my patch, if you uploaded a file and didn't submit it, you carried it around with you until you did submit it, or your session expired.
  2. since the issue has been around for a long time, and nobody else has reported it, i'm considering it a low priority item to fix
  3. when issue followups as comments lands, this will actually be taken care of for all releases > Drupal 5.x

i'm leaving this set to active, and recommending that if anybody wants it fixed in versions < Drupal 6.x, to work up a patch that adds a 'Remove file' button any time there's a file already in 'file_issue', and i'll be happy to commit it once we branch for Drupal 5.

hunmonk’s picture

Assigned: hunmonk » Unassigned
Priority: Normal » Minor
hunmonk’s picture

Version: 5.x-2.x-dev » 5.x-1.x-dev
Status: Active » Patch (to be ported)

no longer a problem since IFAC landed. could use a backport of the recommended fix if anybody is interested.

aclight’s picture

Status: Patch (to be ported) » Fixed

Since we're no longer supporting the 5.x-1.x branch of pi, I'm setting this to fixed.

dww’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev

Sounds good. Fixed in 5.x-2.x-dev then. ;)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.