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

Files: New custom description format_string call

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9
    • Fix Version/s: 2.9
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      Hide

      1. Go to the filetypes tool (Admin/Server/Filetypes).
      2. Edit a filetype (e.g. PDF) and use a custom description, e.g. 'Annoying document'
      3. Go to any website and add a File resource. Upload a PDF. Under 'Appearance', set the type to 'Embed' and turn on the option about displaying file type. Save and display.
      EXPECTED: It should not show a debugging message.

      Show
      1. Go to the filetypes tool (Admin/Server/Filetypes). 2. Edit a filetype (e.g. PDF) and use a custom description, e.g. 'Annoying document' 3. Go to any website and add a File resource. Upload a PDF. Under 'Appearance', set the type to 'Embed' and turn on the option about displaying file type. Save and display. EXPECTED: It should not show a debugging message.
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-48946-master

      Description

      When I changed flielib to allow for custom descriptions, I used the format_string function so that it can support the multilang filter if enabled.

      Unfortunately I did not specify a context, which means it uses the page context. There are situations where code might get a file description before the page context has been defined. For example, if you have a File resource that has the 'display type' option turned on, then rebuilding the course cache will result in getting the description. This is something that can happen very early on a page if you call get_fast_modinfo, which you might do before knowing the context.

      When this happens you get a debugging warning (and I presume it uses the system context).

      Because this behaviour is not very predictable I think it's better to explicitly use the system context here, meaning that the multilang filter will only work on this text if turned on at system level.

        Attachments

          Activity

            People

            Assignee:
            quen Sam Marshall
            Reporter:
            quen Sam Marshall
            Peer reviewer:
            David Monllaó
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Zachary Durber
            Participants:
            Component watchers:
            Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/15