Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-33

Delay uploaded file handling till form validation passes

    XMLWordPrintable

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.1.0
    • Fix Version/s: 5.2.0
    • Component/s: File Uploader
    • Labels:
      None
    • Additional information:
      Hide

      This is what happens in what order:

      1. OnSave event is called.
      2. withing OnSave event method "kDBItem::SetFieldsFromHash" is called
      3. method "kDBItem::SetFieldsFromHash" calls "kUploadFormatter::Parse" method
        Last of mentioned methods actually performs file moving from temp directory to target directory.

      And only after that form validation happens when "OnPreSave" event is called.

      So Parse method actually doesn't know anything about validation result, because no validation happened at that moment.

      Instead of actually moving files I propose to put moving operations to "<prefix_special>pending_actions<m_wid>" variable (it is kind of queue).

      Queue processing should be made in OnSave event (when temporary tables are used) and in OnAfterItemUpdate/OnAfterItemCreate (when temporary tables are not used).


      By no "pending_actions" variable is used only to schedule uploaded file deletion operation. This processing should be joined with file moving and centrally processed in one place.

      Show
      This is what happens in what order: OnSave event is called. withing OnSave event method "kDBItem::SetFieldsFromHash" is called method "kDBItem::SetFieldsFromHash" calls "kUploadFormatter::Parse" method Last of mentioned methods actually performs file moving from temp directory to target directory. And only after that form validation happens when "OnPreSave" event is called. So Parse method actually doesn't know anything about validation result, because no validation happened at that moment. Instead of actually moving files I propose to put moving operations to "<prefix_special> pending_actions <m_wid>" variable (it is kind of queue). Queue processing should be made in OnSave event (when temporary tables are used) and in OnAfterItemUpdate/OnAfterItemCreate (when temporary tables are not used). By no "pending_actions" variable is used only to schedule uploaded file deletion operation. This processing should be joined with file moving and centrally processed in one place.
    • Change Log Group:
      Fixed
    • Change Log Message:
      Uploaded files were available in "/system" folder even after form validation error.
    • Story Points:
      2
    • External issue ID:
      43
    • Copy Issue Key:
    • Patch Instructions:

      Patches must be submitted through Phabricator.

      Description

      When "inp_edit_swfupload" block is used on form, then selected files are actually uploaded in two cases:

      1. when "upload" button is pressed (under uploader control)
      2. when "save" button is pressed (on top of form)

      By default SWFUploader uploads files in temp directory ("/system/tmp") and when saving record to database ("save" button pressed) is moving uploaded files from temp directory to actual directory, specified in unit config.

      But, when we have some invalid data on form, like required field value is not entered and "save" button is pressed, then we are returned to form with validation errors displayed, but are already uploaded to target directory.

      Files, uploaded to temp directory should only be moved to target directory when "save" button is pressed and there are not validation errors on form.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                alex Alex
                Developer:
                Alex
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: