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

File cache store doesn't check if file exists if prescan is enabled

    XMLWordPrintable

    Details

      Description

      The code: \cachestore_file->get

              if ($this->prescan && array_key_exists($key, $this->keys)) {
                  if (!$ttl || $this->keys[$filename] >= $maxtime && file_exists($file)) {
                      $readfile = true;
                  } else {
                      $this->delete($key);
                  }
      

      And in particular, this line:

      if (!$ttl || $this->keys[$filename] >= $maxtime && file_exists($file)) {
      

      Parentheses are needed around the TTL and max time checks, otherwise file_exists is completely ignored. Testing it in PHP interpreter:

      // Without parentheses.
      php > var_dump((true || false && false));
      bool(true)
      // With parentheses.
      php > var_dump(((true || false) && false));
      bool(false)
      

        Attachments

          Activity

            People

            Assignee:
            marina Marina Glancy
            Reporter:
            bushido Mark Nielsen
            Peer reviewer:
            John Okely
            Integrator:
            David Monllaó
            Tester:
            Frédéric Massart
            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:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/Sep/15