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:
    • Rank:
      17563

      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

        Issue Links

          Activity

          Hide
          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
          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
          Helen Foster added a comment -

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

          Show
          Helen Foster added a comment - Just noting that this issue is mentioned in MDLQA-1147 .
          Hide
          David Mudrak added a comment -

          Assigning to Dongsheng as he was working on the duplicate.

          Show
          David Mudrak added a comment - Assigning to Dongsheng as he was working on the duplicate.
          Hide
          Andrew Davis added a comment -

          This is still an issue in 2.1.1 Attaching another screenshot.

          Show
          Andrew Davis added a comment - This is still an issue in 2.1.1 Attaching another screenshot.
          Hide
          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
          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
          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
          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
          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
          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 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 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
          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
          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
          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
          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
          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
          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
          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 Cai added a comment -

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

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

          Thanks Jamie, this patch looks good to me

          Show
          Dongsheng Cai added a comment - Thanks Jamie, this patch looks good to me
          Hide
          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
          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
          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
          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
          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
          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
          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
          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
          Sam Hemelryk added a comment -

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

          Cheers
          sam

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

          Thanks Sam.

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

          works for me!
          Thanks

          Show
          Ankit Agarwal added a comment - works for me! Thanks
          Hide
          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
          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: