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

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

    XMLWordPrintable

    Details

    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull Master Branch:
      MDL-49034_master

      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

            Assignee:
            mattp@catalyst-au.net Matt Porritt
            Reporter:
            mattp@catalyst-au.net Matt Porritt
            Peer reviewer:
            Mark Nelson
            Integrator:
            David Monllaó
            Tester:
            Dave Cooper
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              9/Mar/15