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

Adding a really long file name as the filename of a backup is not handled by Moodle

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3, 3.4
    • 3.3.4, 3.4.1
    • Backup
    • MOODLE_23_STABLE, MOODLE_34_STABLE
    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • MDL-33886-master
    • Hide

      Testing instructions:

      1. Log into Moodle as Admin
      2. Create a new / use an existing Moodle Course
      3. Select Backup option for Moodle Course
      4. Go through the Backup workflow (don't use the "Jump to final step" shortcut)
      5. Specify a MBZ filename with over 255 characters long on step 3. "Confirmation and review"
      6. You should receive an error validation message after clicking on "Perform backup" button saying: "The filename length you enter must be less than 255 characters"
      7. You should not receive an un-handled error message as previously reported
      Show
      Testing instructions: Log into Moodle as Admin Create a new / use an existing Moodle Course Select Backup option for Moodle Course Go through the Backup workflow (don't use the "Jump to final step" shortcut) Specify a MBZ filename with over 255 characters long on step 3. "Confirmation and review" You should receive an error validation message after clicking on "Perform backup" button saying: "The filename length you enter must be less than 255 characters" You should not receive an un-handled error message as previously reported

    Description

      Moodle generates an exception when the user enters a really long filename as the name of a backup file. The filename column in mdl_files is varchar (255). If you exceed 255 characters, the exception generated is not handled by Moodle. A generic error is produced that, unless debug is turned on, doesn't tell the user what is broken.

      I sincerely doubt this is a regression bug caused by any 2.3 changes!!

      To recreate:

      Pre-requisites:

      • An existing course with plenty of data.

      Test Steps:

      1. Backup the course and enter more than 255 characters as the filename of the backup.

      Expected result:

      • Moodle gracefully informs the user that the filename is too long.

      Actual result:

      • Moodle generates the following error:

      Can not create file "31/backup/course/0///123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12.mbz"

      More information about this error
      Debug info: Data too long for column 'filename' at row 1
      INSERT INTO mdl_files (contextid,component,filearea,itemid,filepath,filename,timecreated,timemodified,mimetype,userid,source,author,license,status,sortorder,filesize,contenthash,pathnamehash) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
      [array (
      0 => '31',
      1 => 'backup',
      2 => 'course',
      3 => 0,
      4 => '/',
      5 => '123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12.mbz',
      6 => 1340177941,
      7 => 1340177941,
      8 => 'application/vnd.moodle.backup',
      9 => '2',
      10 => NULL,
      11 => NULL,
      12 => NULL,
      13 => 0,
      14 => 0,
      15 => 1254809,
      16 => 'dae2ae7ef894d6cdc517264f7a77fa0464c81e56',
      17 => 'd13cd587ebdd3bfcd10e02dbf7d2067039103df0',
      )]
      Error code: storedfilenotcreated
      Stack trace:

      line 1049 of /lib/filestorage/file_storage.php: stored_file_creation_exception thrown
      line 313 of /backup/util/helper/backup_helper.class.php: call to file_storage->create_file_from_pathname()
      line 1595 of /backup/moodle2/backup_stepslib.php: call to backup_helper::store_backup_file()
      line 34 of /backup/util/plan/backup_execution_step.class.php: call to backup_store_backup_file->define_execution()
      line 153 of /backup/util/plan/base_task.class.php: call to backup_execution_step->execute()
      line 146 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
      line 110 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
      line 309 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
      line 111 of /backup/util/ui/backup_ui.class.php: call to backup_controller->execute_plan()
      line 89 of /backup/backup.php: call to backup_ui->execute()

      Attachments

        Issue Links

          Activity

            People

              zig Zig Tan (Inactive)
              timb Tim Barker
              Mihail Geshoski Mihail Geshoski
              David Monllaó David Monllaó
              Rayna Mae Jayco Rayna Mae Jayco
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                15/Jan/18