phpBB

Code Changes

File: phpbb/cache/driver/file.php

  Unmodified   Added   Modified   Removed
Line 37Line 37
		$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir');
$this->filesystem = new \phpbb\filesystem\filesystem();


		$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir');
$this->filesystem = new \phpbb\filesystem\filesystem();


		if (!is_dir($this->cache_dir))

		if ($this->filesystem->is_writable(dirname($this->cache_dir)) && !is_dir($this->cache_dir))

		{

		{

			@mkdir($this->cache_dir, 0777, true);

			mkdir($this->cache_dir, 0777, true);

		}
}


		}
}


Line 328Line 328
		}

return $query_result;

		}

return $query_result;

 
	}

/**
* Cleanup when loading invalid data global file
*
* @param string $file Filename
* @param resource $handle
*
* @return void
*/
private function cleanup_invalid_data_global(string $file, $handle): void
{
if (is_resource($handle))
{
fclose($handle);
}

$this->vars = $this->var_expires = [];
$this->is_modified = false;

$this->remove_file($file);

	}

/**

	}

/**

Line 372Line 393

if (!is_numeric($bytes) || ($bytes = (int) $bytes) === 0)
{


if (!is_numeric($bytes) || ($bytes = (int) $bytes) === 0)
{

					// We cannot process the file without a valid number of bytes
// so we discard it
fclose($handle);

$this->vars = $this->var_expires = array();
$this->is_modified = false;

$this->remove_file($file);

					$this->cleanup_invalid_data_global($file, $handle);









return false;
}


return false;
}

Line 392Line 406
				}

$var_name = substr(fgets($handle), 0, -1);

				}

$var_name = substr(fgets($handle), 0, -1);

 
				$data_length = $bytes - strlen($var_name);

if ($data_length <= 0)
{
$this->cleanup_invalid_data_global($file, $handle);

return false;
}


// Read the length of bytes that consists of data.


// Read the length of bytes that consists of data.

				$data = fread($handle, $bytes - strlen($var_name));

				$data = fread($handle, $data_length);

				$data = @unserialize($data);

// Don't use the data if it was invalid

				$data = @unserialize($data);

// Don't use the data if it was invalid

Line 581Line 603

try
{


try
{

				$this->filesystem->phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE);

				$this->filesystem->phpbb_chmod($file, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE);

			}
catch (\phpbb\filesystem\exception\filesystem_exception $e)
{

			}
catch (\phpbb\filesystem\exception\filesystem_exception $e)
{