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

mod_data bug when only a file field and no file in a record

    XMLWordPrintable

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide
      1. Enable portfolios [Site administration ► Advanced features].
      2. Enable a portfolio (File download require little in the way of configuration) [Site administration ► Plugins ► Portfolios ► Manage portfolios].
      3. Create a database activity.
      4. Important Create only one (file) field. The code segment being tested only works if there is one field in the database activity.
      5. Click on the Templates tab and save the templates.
      6. Create an entry and leave the file field blank.
      7. View in both list view and single view and check that there are no errors displayed.
      Show
      Enable portfolios [Site administration ► Advanced features] . Enable a portfolio (File download require little in the way of configuration) [Site administration ► Plugins ► Portfolios ► Manage portfolios] . Create a database activity. Important Create only one (file) field. The code segment being tested only works if there is one field in the database activity. Click on the Templates tab and save the templates. Create an entry and leave the file field blank. View in both list view and single view and check that there are no errors displayed.
    • Workaround:
      Hide

      Do either of the following:

      • disable $CFG->enableportfolios
      • use the attached diff to fix the problem
      Show
      Do either of the following: disable $CFG->enableportfolios use the attached diff to fix the problem
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-44501-master

      Description

      If a database activity contains only a single File field and a record is created with no file attached, there is an error when displaying the record if Moodle's portfolio export component is activated.

      To reproduce:

      1. enable $CFG->enableportfolios
      2. create a Database activity (default settings)
      3. create a single File field
      4. add a record, but don't include any file

      Moodle will try to display the record, yielding the following error:

      Fatal error: Call to a member function get_mimetype() on a non-object in /var/www/moodlecode/25/mod/data/locallib.php on line 353
      

        Attachments

          Activity

            People

            Assignee:
            abgreeve Adrian Greeve
            Reporter:
            monidu Nicolas Dunand
            Peer reviewer:
            Andrew Nicols
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Andrew Davis
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/Jul/14