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

            marina Marina Glancy
            bushido Mark Nielsen
            John Okely John Okely
            David Monllaó David Monllaó
            Frédéric Massart Frédéric Massart
            Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Sep/15