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

enrol table name field length can be violated by self enrol form

    XMLWordPrintable

Details

    • MOODLE_27_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MDL-49034_master
    • Hide
      Test 1
      1. Visit a course.
      2. Click on 'Course administration' > 'Users' > 'Enrolment methods'.
      3. Choose to add an enrolment method from the drop down.
      4. Try and enter very long string (more than 255 chars - it shouldn't let you surpass this limit) in the 'Custom instance name' field, submit and make sure there is no DB error.
      5. Try again, but this time with a string longer than 50 chars (again - it should stop you at the 50 char mark) in the 'Enrolment key' field, submit and make sure there is no DB error.
      Test 2
      1. Visit a course.
      2. Click on 'Course administration' > 'Users' > 'Enrolment methods'.
      3. Choose to add an enrolment method from the drop down.
      4. On your favourite browser HTML editor edit the input fields 'Custom instance name' and 'Enrolment key' and remove the maxlength attribute.
      5. Enter a very long strong (more than 255 chars) in the 'Custom instance name' field.
      6. Enter a very long string (more than than 50 chars) in the 'Enrolment key' field.
      7. Submit and check that you are given a warning above both input fields specifying the maximum characters you are allowed.
      Show
      Test 1 Visit a course. Click on 'Course administration' > 'Users' > 'Enrolment methods'. Choose to add an enrolment method from the drop down. Try and enter very long string (more than 255 chars - it shouldn't let you surpass this limit) in the 'Custom instance name' field, submit and make sure there is no DB error. Try again, but this time with a string longer than 50 chars (again - it should stop you at the 50 char mark) in the 'Enrolment key' field, submit and make sure there is no DB error. Test 2 Visit a course. Click on 'Course administration' > 'Users' > 'Enrolment methods'. Choose to add an enrolment method from the drop down. On your favourite browser HTML editor edit the input fields 'Custom instance name' and 'Enrolment key' and remove the maxlength attribute. Enter a very long strong (more than 255 chars) in the 'Custom instance name' field. Enter a very long string (more than than 50 chars) in the 'Enrolment key' field. Submit and check that you are given a warning above both input fields specifying the maximum characters you are allowed.

    Description

      When adding an enrolment method of "self enrol" to a course, the "Custom instance name" form field allows more than 255 characters. When the form is submitted an error writing to database is thrown as the corresponding field "name" in the table mdl_enrol is set to varchar(255).

      There are two ways of fixing this:
      1. limit the max length of characters in the form field
      2. increase the size or change the field type in the database

      I would suggest the first option mainly for the reason that very long names look bad on most user interfaces and there is a description field available if more words are required.

      This also raises the question of how many forms exhibit this behaviour?

      Attachments

        Activity

          People

            mattp@catalyst-au.net Matt Porritt
            mattp@catalyst-au.net Matt Porritt
            Mark Nelson Mark Nelson
            David Monllaó David Monllaó
            Dave Cooper Dave Cooper
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9/Mar/15