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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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 Master Branch:
      MDL-39422-master

      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

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            poltawski 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
            poltawski 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
            poltawski 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
            poltawski 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
            samhemelryk Sam Hemelryk added a comment -

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

            Cheers
            Sam

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

            Seems to be working fine. Passing.

            Show
            andyjdavis Andrew Davis added a comment - Seems to be working fine. Passing.
            Hide
            poltawski 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
            poltawski 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:
                  Fix Release Date:
                  13/May/13