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

Text being replaced with "1"

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.6.3, 2.7
    • 2.6.6, 2.7.3
    • Caching
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • 46151-28
    • Hide

      Use the memcached store instead of the memcache one.

      If you can't do that, for whatever reason, you could try updating the PHP memcache module to 3.0.8 (which seems to still be in beta)

      Show
      Use the memcached store instead of the memcache one. If you can't do that, for whatever reason, you could try updating the PHP memcache module to 3.0.8 (which seems to still be in beta)
    • Hide

      Ideally this needs to be tested on two versions of the memcache php extension - likely this means rolling your own and I'd recommend starting with the lower version.

      1. Configure Moodle to run unit tests with memcache
      2. Run full unit tests with php using memcache extension version 2.x
      3. Run full unit tests with php using memcache extension version 3.x
      4. Configure MUC to use memcache and browse around the site to look for problems.
      Show
      Ideally this needs to be tested on two versions of the memcache php extension - likely this means rolling your own and I'd recommend starting with the lower version. Configure Moodle to run unit tests with memcache Run full unit tests with php using memcache extension version 2.x Run full unit tests with php using memcache extension version 3.x Configure MUC to use memcache and browse around the site to look for problems.

    Description

      With a certain configuration of Moodle, we are seeing certain text strings being replaced with the digit 1. To reproduce:

      On a Moodle 2.6+ server with:

      • The htmlpurifier cache using a memcache cache store (not memcached)
      • The PHP memcache module version 2.2.4 (other versions may give the same behaviour, but 3.0.8 appears to be different)

      go to the activity chooser a number of times (completely refreshing the page each time) and click assignment. Eventually the help text in the right hand panel will change to "1".

      The root cause of this seems to be that the purify_html() function in weblib.php is caching a boolean true to indicate that a string has not been changed, but with the setup above is receiving a string "1" instead of a properly typed boolean, and is treating this as the purified text.

      This seems to be because older versions of the memcache module do not always return data in the same type as was set, particularly for booleans (where the behaviour is almost undefined given that Memcache::get() returns false for errors and missing data).

      The documentation for the memcache module actually says that it "returns the string associated with the key" (http://www.php.net/manual/en/memcache.get.php), although this doesn't seem to be the case for PHP objects which seem to be serialised and deserialised on the fly.

      As far as we can make out, version 3.0.8 has different behaviour, where data is returned with exactly the same type as when it was set, so this problem doesn't occur. It's not clear which version of the module introduced this change.

      Attachments

        Issue Links

          Activity

            People

              samhemelryk Sam Hemelryk
              maherne Michael Aherne
              Damyon Wiese Damyon Wiese
              Damyon Wiese Damyon Wiese
              Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Nov/14