Moodle
  1. Moodle
  2. MDL-39422

module names should not allow names to be entered beyond 255 characters

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.3
    • Fix Version/s: 2.3.7, 2.4.4
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide

      Sample text [STRING-A]
      "This is a really really really long string which you would think would never ever be used but in actual fact is longer than moodle supports in some fields. Rather than accept this string we should stop it, as its over 255 characters in length, its nearly 260"

      1. Go to a new course as teacher
      2. Using the inline editing button (pencil icon), try to change the title of the news forum to the STRING-A
      3. VERIFY: it won't accept the whole string.
      4. VERIFY: the shortened string is saved without db error
      5. FOR EVERY activity/resource EXCEPT forum, workshop & label
      6. Set the name as the STRING-A
      7. VERIFY: the string is not accepted, with a warning about the length of the string
      8. VERIFY: a shortened string is accepted
      Show
      Sample text [STRING-A] "This is a really really really long string which you would think would never ever be used but in actual fact is longer than moodle supports in some fields. Rather than accept this string we should stop it, as its over 255 characters in length, its nearly 260" Go to a new course as teacher Using the inline editing button (pencil icon), try to change the title of the news forum to the STRING-A VERIFY: it won't accept the whole string. VERIFY: the shortened string is saved without db error FOR EVERY activity/resource EXCEPT forum, workshop & label Set the name as the STRING-A VERIFY: the string is not accepted, with a warning about the length of the string VERIFY: a shortened string is accepted
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull 2.4 Branch:
    • Pull Master Branch:
      MDL-39422-master
    • Rank:
      50071

      Description

      At our University there are some lecturer who add resources with Names longer than 255 chars.
      The URL is: https://mymoodle..../course/modedit.php?add=resource&type=&course=123&section=1&return=0&sr=0

      Now my request is: Is it possible to change <input size="48" name="name" type="text" onblur="validate_mod_resource_mod_form_name(this)" onchange="validate_mod_resource_mod_form_name(this)" id="id_name">

      to something like

      <input size="48" maxlengt="255" name="name" type="text" onblur="validate_mod_resource_mod_form_name(this)" onchange="validate_mod_resource_mod_form_name(this)" id="id_name">

      If the names length is longer as 255 chars there´s follogwing error shown:

      Debug info: ERROR: value too long for type character varying(255)
      INSERT INTO mdl_resource (name,display,filterfiles,course,revision,intro,introformat,timemodified,displayoptions) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9) RETURNING id
      [array (
      'name' => 'bjjbjdsbvjdsbvjdsbvjdsbvjkdsbvjdvbsdkvbdjsvbjdvbsdjvbjsdbvjkdbvjdsbvjdsbvkjsdbvjdsbvksjdbvsdkvbjdsbvjdsvbjssdvjdsvjsdbvjdsbvsbbdjvbjsdbvjbdsjvbdsjbvkdsdjvbdjsbdjsbdvkbjvjskjdbvjksdjbvksdvdjsbkjbjvjsbkdjbvjskjdbjvsjkjdbvsjdkjbvvvvvvvvvvvvvvvvvvvvvjddddddddddddddddddddddddddddddddddddddddddddddskkkkkkkkkkkkkkkkkkkkkkkkskskskskskskskksskkkskdbjdbcbscdbscjbcjksbcsdjbckjbcksdcbjdcbkjsbdjbcksjbdcksdjbcksjbcjdksjdbcjskdjbcjbsjdbcskcbkjbkjsbcjcbsjcbsjcbkjcbsdckjbscjbscsjb',
      'display' => '5',
      'filterfiles' => '0',
      'course' => '648',
      'revision' => 1,
      'intro' => '',
      'introformat' => '1',
      'timemodified' => 1367309963,
      'displayoptions' => 'a:2:

      {s:8:"showsize";i:1;s:8:"showtype";i:1;}

      ',
      )]
      Error code: dmlwriteexception
      Stack trace:
      line 429 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 248 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 857 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 909 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
      line 97 of /mod/resource/lib.php: call to pgsql_native_moodle_database->insert_record()
      line 449 of /course/modedit.php: call to resource_add_instance()

      Thanks,
      Benjamin Droemer
      Ulm University

        Issue Links

          Activity

          Hide
          Dan Poltawski added a comment -

          Thanks for your report Benjamin, there are two things to address this in:

          1. The moodleforms for manually add/editing the forms
          2. The AJAX update by clicking on the course page
          Show
          Dan Poltawski added a comment - Thanks for your report Benjamin, there are two things to address this in: The moodleforms for manually add/editing the forms The AJAX update by clicking on the course page
          Hide
          Dan Poltawski added a comment - - edited

          Sending for integration, forum and workshop already handled it.

          In the course toolbox I did it via a hard limit in the form since it was easier and possibly less likely to be copying and pasting there. But its easy to do a 'nicer' error in moodleforms, so done that there (its also consistent with what workshop and forum already have).

          Show
          Dan Poltawski added a comment - - edited Sending for integration, forum and workshop already handled it. In the course toolbox I did it via a hard limit in the form since it was easier and possibly less likely to be copying and pasting there. But its easy to do a 'nicer' error in moodleforms, so done that there (its also consistent with what workshop and forum already have).
          Hide
          Sam Hemelryk added a comment -

          Thanks Dan, improvements looked spot on and have been integrated now.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Thanks Dan, improvements looked spot on and have been integrated now. Cheers Sam
          Hide
          Andrew Davis added a comment -

          Seems to be working fine. Passing.

          Show
          Andrew Davis added a comment - Seems to be working fine. Passing.
          Hide
          Dan Poltawski added a comment -

          Thanks! You're changes are now spread to the world through this git and our source control repositories.

          No time to rest though, we've got days to make 2.5 the best yet!

          ciao

          Show
          Dan Poltawski added a comment - Thanks! You're changes are now spread to the world through this git and our source control repositories. No time to rest though, we've got days to make 2.5 the best yet! ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: