Moodle
  1. Moodle
  2. MDL-29231

Wrong icon can appear next to a file resource

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.0.6, 2.1.3
    • Component/s: Course, Resource
    • Labels:
    • Testing Instructions:
      Hide
      1. Enable editing of a course
      2. Add a resource that is a file
      3. In the uploader, upload a PDF and Word document
      4. Click on the 'Save and return to course' button.
      5. Click on the file link and you should be shown a link to the same file type as indicated by the icon
      Show
      Enable editing of a course Add a resource that is a file In the uploader, upload a PDF and Word document Click on the 'Save and return to course' button. Click on the file link and you should be shown a link to the same file type as indicated by the icon
    • Workaround:
      Hide

      Upload files into a folder instead.
      Don't upload two files into one resource.

      Show
      Upload files into a folder instead. Don't upload two files into one resource.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-29231-master
    • Rank:
      18774

      Description

      When adding two files to one file resource in a course, the wrong icon can be displayed.

      This is cosmetic only.

      Replication instructions:

      1. Enable editing of a course
      2. Add a resource that is a file
      3. In the uploader, upload a PDF and Word document
      4. Click on the 'Save and return to course' button.

      You could now have the PDF icon, but when you click on it you get the word document. Or inversely you could get the Word document icon, but instead download the PDF.

      You can invert the icons and the documents by changing the main file.

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          Thanks for reporting this. I can confirm the problem.

          I've put it on our backlog and we'll try to get to it as soon as we can.

          In the meantime feel free to help us work on this issue. If you do add a solution, please add a 'patch' label.

          Show
          Michael de Raadt added a comment - Thanks for reporting this. I can confirm the problem. I've put it on our backlog and we'll try to get to it as soon as we can. In the meantime feel free to help us work on this issue. If you do add a solution, please add a 'patch' label.
          Hide
          Michael de Raadt added a comment -

          The problem appears in the navigation also.

          Show
          Michael de Raadt added a comment - The problem appears in the navigation also.
          Hide
          Jason Fowler added a comment -

          Diff to patch the error

          Show
          Jason Fowler added a comment - Diff to patch the error
          Hide
          Jason Fowler added a comment -

          Fixed by ensuring the last file loaded is linked to by default, as that is the one the icon is derived from

          Show
          Jason Fowler added a comment - Fixed by ensuring the last file loaded is linked to by default, as that is the one the icon is derived from
          Hide
          Michael de Raadt added a comment -

          I thought I should follow up on this to avoid confusion in future.

          There doesn't appear to be a problem with view.php. It is delivering the correct file.

          The choice of mainfile in mod/resource/lib.php seems to be choosing the incorrect file and so the icons are appearing incorrectly. To fix this, the choice of mainfile should be the same as the choice in view.php. This can be achieved by changing...

          mod/resource/lib.php, line 260
          $mainfile = array_pop($files);
          

          ...to...

          $mainfile = reset($files);
          

          ...which will return a reference to the first file object rather than the object itself (I believe).

          This fix should be checked.

          Show
          Michael de Raadt added a comment - I thought I should follow up on this to avoid confusion in future. There doesn't appear to be a problem with view.php. It is delivering the correct file. The choice of mainfile in mod/resource/lib.php seems to be choosing the incorrect file and so the icons are appearing incorrectly. To fix this, the choice of mainfile should be the same as the choice in view.php. This can be achieved by changing... mod/resource/lib.php, line 260 $mainfile = array_pop($files); ...to... $mainfile = reset($files); ...which will return a reference to the first file object rather than the object itself (I believe). This fix should be checked.
          Hide
          Ankit Agarwal added a comment -

          Hi Jason,
          Looks good!

          Unrelated Question to discuss :why do we allow multiple files to be uploaded in such a situation, if there is no way to access those files?
          Thanks

          Show
          Ankit Agarwal added a comment - Hi Jason, Looks good! Unrelated Question to discuss :why do we allow multiple files to be uploaded in such a situation, if there is no way to access those files? Thanks
          Hide
          Sam Hemelryk added a comment -

          Thanks guys - this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks guys - this has been integrated now
          Hide
          Rossiani Wijaya added a comment -

          I noticed that docs file doesn't contain any link in navigation blocks. Is this on purpose?

          Show
          Rossiani Wijaya added a comment - I noticed that docs file doesn't contain any link in navigation blocks. Is this on purpose?
          Hide
          Rossiani Wijaya added a comment -

          Patch is looking good.

          I will wait for Sam to comment on this issue before passing this issue.

          Show
          Rossiani Wijaya added a comment - Patch is looking good. I will wait for Sam to comment on this issue before passing this issue.
          Hide
          Sam Hemelryk added a comment -

          Hi Rosie
          Can you explain what you are seeing and how to replicate it?
          I'll give it a shot this afternoon.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hi Rosie Can you explain what you are seeing and how to replicate it? I'll give it a shot this afternoon. Cheers Sam
          Hide
          Rossiani Wijaya added a comment -

          Hi Sam,

          I create a new issue to discuss the link in navigation blocks (MDL-29944).

          I'm passing this issue.

          Test passed.

          Show
          Rossiani Wijaya added a comment - Hi Sam, I create a new issue to discuss the link in navigation blocks ( MDL-29944 ). I'm passing this issue. Test passed.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Done, your delicious hacks have been sent upstream, many thanks!

          Closing as fixed, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Done, your delicious hacks have been sent upstream, many thanks! Closing as fixed, ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: