Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27919

Name of file undefined after selecting a file from my private files and clsoing file picker

    Details

    • Testing Instructions:
      Hide

      I have now tested the use of the file picker in the file manager, the html editor and the filepicker form component and they all work.
      In each component I tested :

      • uploading a file that did not previously exist
      • and uploaded files with the same name as an existing file
      • and tested choices "Overwrite" existing file and "Rename file" choices all worked

      After the fix the filename and url in the element (filepicker form element, html editor and filemanager form component) using the file picker worked appeared properly.

      Show
      I have now tested the use of the file picker in the file manager, the html editor and the filepicker form component and they all work. In each component I tested : uploading a file that did not previously exist and uploaded files with the same name as an existing file and tested choices "Overwrite" existing file and "Rename file" choices all worked After the fix the filename and url in the element (filepicker form element, html editor and filemanager form component) using the file picker worked appeared properly.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull Master Branch:

      Description

      The name of file shows as undefined after selecting a file from "my private files" and closing the file picker. The file ends up working correctly, the name is incorrect. I have tried this in restoring course backups. Adding an item in the Image Gallery type database activity and others. I have included a screen shot when add an image to the Image Gallery type database activity.

      Replication instructions:

      1. Log in to http://qa.moodle.net/ as a teacher or a student.
      2. Go to your My Private files and upload an image and same changes.
      3. Go to the Moodle features demo (http://qa.moodle.net/course/view.php?id=2)
      4. And then the image gallery database activity(http://qa.moodle.net/mod/data/view.php?id=17)
      5. Add entry
      6. When choosing an image to attach, add the image from your my private files area
      7. Close file picker

      file name is undefined instead of actual file name
      This is before saving the entry

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              salvetore Michael de Raadt added a comment -

              Hi, Michael.

              I assume you found this while completing QA tests, but it is not a failed QA test case. If I am wrong, please comment here.

              Michael;

              Show
              salvetore Michael de Raadt added a comment - Hi, Michael. I assume you found this while completing QA tests, but it is not a failed QA test case. If I am wrong, please comment here. Michael;
              Hide
              tsala Helen Foster added a comment -

              Just noting that this issue is mentioned in MDLQA-1147.

              Show
              tsala Helen Foster added a comment - Just noting that this issue is mentioned in MDLQA-1147 .
              Hide
              mudrd8mz David Mudrák added a comment -

              Assigning to Dongsheng as he was working on the duplicate.

              Show
              mudrd8mz David Mudrák added a comment - Assigning to Dongsheng as he was working on the duplicate.
              Hide
              andyjdavis Andrew Davis added a comment -

              This is still an issue in 2.1.1 Attaching another screenshot.

              Show
              andyjdavis Andrew Davis added a comment - This is still an issue in 2.1.1 Attaching another screenshot.
              Hide
              jamiesensei Jamie Pratt added a comment -

              This is still an issue in 2.2 dev and 2.1 branch.

              It is not just when selecting a file from private files but also when selecting a file from the recent files tab that the file name back in the form turns up as 'undefined'.

              Show
              jamiesensei Jamie Pratt added a comment - This is still an issue in 2.2 dev and 2.1 branch. It is not just when selecting a file from private files but also when selecting a file from the recent files tab that the file name back in the form turns up as 'undefined'.
              Hide
              jamiesensei Jamie Pratt added a comment -

              I also see the same problem when selecting a file from 'Server Files'.

              1. Choose any form that has a filepicker component. Eg. the image upload field in the user profile editing form is an easy one to play with.
              2. Press the 'Choose a File..' button.
              3. Choose 'Private Files', 'Recent Files' or 'Server Files'
              4. Press 'Select This File'
              5. 'Undefined' will appear as the name of the file in the file picker as shown in Screen-shot-1.png that Andrew uploaded.

              Show
              jamiesensei Jamie Pratt added a comment - I also see the same problem when selecting a file from 'Server Files'. 1. Choose any form that has a filepicker component. Eg. the image upload field in the user profile editing form is an easy one to play with. 2. Press the 'Choose a File..' button. 3. Choose 'Private Files', 'Recent Files' or 'Server Files' 4. Press 'Select This File' 5. 'Undefined' will appear as the name of the file in the file picker as shown in Screen-shot-1.png that Andrew uploaded.
              Hide
              jamiesensei Jamie Pratt added a comment - - edited

              I also tried installing a further repository plug in. I installed the picasa plug in. I found I could select a file from the picasa plug in and the name correctly showed up as expected in the filepicker form field.

              Show
              jamiesensei Jamie Pratt added a comment - - edited I also tried installing a further repository plug in. I installed the picasa plug in. I found I could select a file from the picasa plug in and the name correctly showed up as expected in the filepicker form field.
              Hide
              dongsheng Dongsheng Cai added a comment -

              Hi all

              It's the filepicker form element issue, it uses a wrong javascript array key, I will look into this one on Monday.

              Show
              dongsheng Dongsheng Cai added a comment - Hi all It's the filepicker form element issue, it uses a wrong javascript array key, I will look into this one on Monday.
              Hide
              jamiesensei Jamie Pratt added a comment -

              Hi Dongsheng,

              I have a patch for this you can look at. It should apply cleanly to the Moodle 2.1 branch too.

              As you say the filepicker code was using the wrong keys of the param value, the 'file' key was not being set.

              As well as the cases above I found that when Renaming an existing file both the 'file' key and the 'url' where not being passed back from the ajax.

              When overwriting an existing file I also thought it was helpful to call M.form_filepicker.callback. My code in a new question type listens for calls to this function and loads the file (using Y.after), which my code loads the image file and displays it in a preview area. Listening to the function call in this way might be useful in many situations. If we call the function even when the file name has not actually changed although the file has changed then code can listen to the function call to know that a new file has been uploaded.

              This 'call function even when filename has not changed' is coded in my second commit.

              Can you take a look at this branch and consider applying these patches to 2.1 and master branch?

              https://github.com/jamiepratt/moodle/compare/master...MDL-27919

              Thanks!

              Jamie

              Show
              jamiesensei Jamie Pratt added a comment - Hi Dongsheng, I have a patch for this you can look at. It should apply cleanly to the Moodle 2.1 branch too. As you say the filepicker code was using the wrong keys of the param value, the 'file' key was not being set. As well as the cases above I found that when Renaming an existing file both the 'file' key and the 'url' where not being passed back from the ajax. When overwriting an existing file I also thought it was helpful to call M.form_filepicker.callback. My code in a new question type listens for calls to this function and loads the file (using Y.after), which my code loads the image file and displays it in a preview area. Listening to the function call in this way might be useful in many situations. If we call the function even when the file name has not actually changed although the file has changed then code can listen to the function call to know that a new file has been uploaded. This 'call function even when filename has not changed' is coded in my second commit. Can you take a look at this branch and consider applying these patches to 2.1 and master branch? https://github.com/jamiepratt/moodle/compare/master...MDL-27919 Thanks! Jamie
              Hide
              jamiesensei Jamie Pratt added a comment -

              Ooops. I didn't realise that this filepicker.js code was also used by the html editor and I think also the filemanager. This patch may cause some regressions there. Will take a look in a couple of hours.

              Show
              jamiesensei Jamie Pratt added a comment - Ooops. I didn't realise that this filepicker.js code was also used by the html editor and I think also the filemanager. This patch may cause some regressions there. Will take a look in a couple of hours.
              Hide
              jamiesensei Jamie Pratt added a comment -

              I have fixed a regression where I was seeing that after choosing "Overwrite" in a filemanager form component when subsequently trying to add another file the file picker would immediately close upon opening.

              • I have now tested the use of the file picker in the file manager, the html editor and the filepicker form component and they all work.
              • In each component I tested :
                • uploading a file that did not previously exist
                • and uploaded files with the same name as an existing file
                • and tested choices "Overwrite" existing file and "Rename file" choices all worked
                • and that subsequently the filename and url in the element (filepicker form element, html editor and filemanager form component) using the file picker worked appeared properly.
              Show
              jamiesensei Jamie Pratt added a comment - I have fixed a regression where I was seeing that after choosing "Overwrite" in a filemanager form component when subsequently trying to add another file the file picker would immediately close upon opening. I have now tested the use of the file picker in the file manager, the html editor and the filepicker form component and they all work. In each component I tested : uploading a file that did not previously exist and uploaded files with the same name as an existing file and tested choices "Overwrite" existing file and "Rename file" choices all worked and that subsequently the filename and url in the element (filepicker form element, html editor and filemanager form component) using the file picker worked appeared properly.
              Show
              jamiesensei Jamie Pratt added a comment - I have committed my fix for the regression here : https://github.com/jamiepratt/moodle/commit/1ae299f5f3bb79d4e45726baec0afce746cd03a1 It is on my branch https://github.com/jamiepratt/moodle/compare/master...MDL-27919
              Hide
              dongsheng Dongsheng Cai added a comment -

              Re-assign to Jamie, because Jamie provided a patch for this issue.

              Show
              dongsheng Dongsheng Cai added a comment - Re-assign to Jamie, because Jamie provided a patch for this issue.
              Hide
              dongsheng Dongsheng Cai added a comment -

              Thanks Jamie, this patch looks good to me

              Show
              dongsheng Dongsheng Cai added a comment - Thanks Jamie, this patch looks good to me
              Hide
              jamiesensei Jamie Pratt added a comment -

              Hi,

              It seems this has not been included in Moodle yet. What do we have to do to get this fix into Moodle? Am not sure why the status is set to 'In Development'. Dongsheng is the right person to peer review this I think since I think he wrote the original filepicker code.

              This is not related to the other issue I created where I was arguing we should use the filepicker instead of the file manager for uploading a single file.

              Jamie

              Show
              jamiesensei Jamie Pratt added a comment - Hi, It seems this has not been included in Moodle yet. What do we have to do to get this fix into Moodle? Am not sure why the status is set to 'In Development'. Dongsheng is the right person to peer review this I think since I think he wrote the original filepicker code. This is not related to the other issue I created where I was arguing we should use the filepicker instead of the file manager for uploading a single file. Jamie
              Hide
              jamiesensei Jamie Pratt added a comment - - edited

              Seems it was Dongsheng who set status to 'Development in Progress'. I would have thought that meant that there was some more coding to do. Mistake? Have not found a document yet that explains the current development process and explains how we use the tracker - the meaning of the status and labels such as triage.

              Oh! Strike that I found it and better have a good read now : http://docs.moodle.org/dev/Process

              Show
              jamiesensei Jamie Pratt added a comment - - edited Seems it was Dongsheng who set status to 'Development in Progress'. I would have thought that meant that there was some more coding to do. Mistake? Have not found a document yet that explains the current development process and explains how we use the tracker - the meaning of the status and labels such as triage. Oh! Strike that I found it and better have a good read now : http://docs.moodle.org/dev/Process
              Hide
              jamiesensei Jamie Pratt added a comment -

              Sorry I have not 2.1 branch but the master branch should apply cleanly to 2.1 I hope.

              Show
              jamiesensei Jamie Pratt added a comment - Sorry I have not 2.1 branch but the master branch should apply cleanly to 2.1 I hope.
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

              TIA and ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
              Hide
              samhemelryk Sam Hemelryk added a comment -

              Thanks for realising this was stagnating Jamie - its now been integrated, the changes looked good.

              Cheers
              sam

              Show
              samhemelryk Sam Hemelryk added a comment - Thanks for realising this was stagnating Jamie - its now been integrated, the changes looked good. Cheers sam
              Hide
              jamiesensei Jamie Pratt added a comment -

              Thanks Sam.

              Show
              jamiesensei Jamie Pratt added a comment - Thanks Sam.
              Hide
              ankit_frenz Ankit Agarwal added a comment -

              works for me!
              Thanks

              Show
              ankit_frenz Ankit Agarwal added a comment - works for me! Thanks
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              And this has been sent upstream (already available @ git and cvs repos). Many, many thanks!

              Closing as fixed, ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - And this has been sent upstream (already available @ git and cvs repos). Many, many thanks! Closing as fixed, ciao

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    28/Nov/11