The code reads:

  function set($cid, $data, $expire = CACHE_PERMANENT) {
    $filename = $this->prefix . $this->encode_cid($cid);

    // Open file for that entry, handling errors that may arise
    $fh = @fopen($filename, 'r+b');
    if ($fh === FALSE) {
      // If file doesn't exist, create it with a+w permissions
      $fh = fopen($filename, 'c+b');
      if ($fh !== FALSE) {
        if (!chmod($filename, 0777)) {

The second comment states "create it with a+w permissions". Then it's opened with "c+b". Shouldn't it be "a+b" to create it for binary read-write access?

Comments

ogi’s picture

Status: Active » Closed (works as designed)

a+w is about access mode (the 0777 later in the code that in a recent commit was changed to 0666). c+b is for fopen mode (open binary file and create it if needed) and is the correct one.