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

MUC: memcache instance key prefix does not allow numeric values

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Add memcache store
      Fill out fields as normal
      Change key prefix to use non-alphanumeric characters
      Save changes

      Click "Edit store"
      (Behaviour before patch)
      Expected result: key prefix is as set.
      Actual result: key prefix has non-alpha chars stripped out.

      (Behaviour after patch)
      On "Save changes" - form responds with error for characters other than [a-zA-Z0-9\-_ ]
      On "Edit store" - key prefix is set as expected.

      Show
      Add memcache store Fill out fields as normal Change key prefix to use non-alphanumeric characters Save changes Click "Edit store" (Behaviour before patch) Expected result: key prefix is as set. Actual result: key prefix has non-alpha chars stripped out. (Behaviour after patch) On "Save changes" - form responds with error for characters other than [a-zA-Z0-9\-_ ] On "Edit store" - key prefix is set as expected.
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull Master Branch:
      wip-MDL-40700-m26

      Description

      When configuring a memcache store, the key prefix field allows the user to submit numbers, and save the changes.
      Because the form definition uses ALPHAEXT for this field, the numbers are stripped out silently.
      A simple fix is to change the field type to ALPHANUMEXT, and add some form validation.

      diff --git a/cache/stores/memcache/addinstanceform.php b/cache/stores/memcache/addinstanceform.php
      index 984966a..29e1239 100644
      --- a/cache/stores/memcache/addinstanceform.php
      +++ b/cache/stores/memcache/addinstanceform.php
      @@ -49,7 +49,7 @@ class cachestore_memcache_addinstance_form extends cachestore_addinstance_form {
               $form->addElement('text', 'prefix', get_string('prefix', 'cachestore_memcache'),
                       array('maxlength' => 5, 'size' => 5));
               $form->addHelpButton('prefix', 'prefix', 'cachestore_memcache');
      -        $form->setType('prefix', PARAM_ALPHAEXT);
      +        $form->setType('prefix', PARAM_ALPHANUMEXT);
               $form->setDefault('prefix', 'mdl_');
           }
      

      Is there a reason behind not allowing numeric prefixes? With a 5 character limit, very few sites can use the same memcache servers, and have meaningful key prefixes.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Sep/13