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

The static cache store does not honour the provided identifiers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 3.5.5
    • Fix Version/s: None
    • Component/s: Caching
    • Labels:
    • Affected Branches:
      MOODLE_35_STABLE

      Description

      The static cache store supports_multiple_identifiers() and a multi-identifier array is generated in generate_multi_key_parts but only the key provided to $cache->get is used to retrieve the key from the static cache.

      The storeid generated by cachestore_static::initialise() does not use the identifiers provided in cache::make().

      The identifiers provided in cache::make() are used in generate_single_key_prefix, but this function is only used for cache stores that do not support multiple identifiers.

      I haven't checked other cache stored, but my conclusion is that cache stores that support multiple identifiers and do not make internal use of the multiple identifiers when setting or getting items do not really support identifiers. This is a problem because, for what I understand, $identifiers are supposed to use for all definitions and all cache stores.

      https://github.com/dmonllao/moodle/compare/MDL-65358_master~...MDL-65358_master

      <?php
       
      define('CLI_SCRIPT', true);
      require_once(__DIR__ . '/config.php');
       
      /**
       * The same issue exists with cache::make() regardless of the cache definition params.
       */
       
      $identifiers = ['one' => 'yeah'];
      $cache = cache::make_from_params(cache_store::MODE_REQUEST, 'core', 'testwithidentifiers', $identifiers);
      $cache->set('itemkey', 'FIRST');
       
      // Different identifiers.
      $identifiers = ['one' => 'not-yeah'];
      $cache = cache::make_from_params(cache_store::MODE_REQUEST, 'core', 'testwithidentifiers', $identifiers);
       
      echo 'It should not return stuff when using different identifiers, but...' . PHP_EOL;
      echo $cache->get('itemkey') . PHP_EOL;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              dmonllao David Monllaó
              Participants:
              Component watchers:
              Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: