1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/13697] Moving filesystem related functions to filesystem service

* Moving filesystem service to \phpbb\filesystem namespace
 * Wraping Symfony's Filesystem component
 * Moving filesystem related functions from includes/functions.php
   into \phpbb\filesystem\filesystem
   Functions moved (and deprecated):
     - phpbb_chmod
     - phpbb_is_writable
     - phpbb_is_absolute
     - phpbb_own_realpath
     - phpbb_realpath
 * Adding interface for filesystem service

PHPBB3-13697
This commit is contained in:
MateBartus
2015-03-12 00:25:00 +01:00
parent f86c5d905b
commit 4bdef6fd21
82 changed files with 1859 additions and 657 deletions

View File

@@ -177,13 +177,9 @@ abstract class base implements \phpbb\cache\driver\driver_interface
*/
function remove_file($filename, $check = false)
{
if (!function_exists('phpbb_is_writable'))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/functions.' . $phpEx);
}
global $phpbb_filesystem;
if ($check && !phpbb_is_writable($this->cache_dir))
if ($check && !$phpbb_filesystem->is_writable($this->cache_dir))
{
// E_USER_ERROR - not using language entry - intended.
trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR);

View File

@@ -20,6 +20,11 @@ class file extends \phpbb\cache\driver\base
{
var $var_expires = array();
/**
* @var \phpbb\filesystem\filesystem_interface
*/
protected $filesystem;
/**
* Set cache path
*
@@ -30,6 +35,7 @@ class file extends \phpbb\cache\driver\base
global $phpbb_root_path, $phpbb_container;
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/';
$this->filesystem = new \phpbb\filesystem\filesystem();
if (!is_dir($this->cache_dir))
{
@@ -69,14 +75,8 @@ class file extends \phpbb\cache\driver\base
if (!$this->_write('data_global'))
{
if (!function_exists('phpbb_is_writable'))
{
global $phpbb_root_path;
include($phpbb_root_path . 'includes/functions.' . $phpEx);
}
// Now, this occurred how often? ... phew, just tell the user then...
if (!phpbb_is_writable($this->cache_dir))
if (!$this->filesystem->is_writable($this->cache_dir))
{
// We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload())
die('Fatal: ' . $this->cache_dir . ' is NOT writable.');
@@ -574,13 +574,14 @@ class file extends \phpbb\cache\driver\base
fclose($handle);
if (!function_exists('phpbb_chmod'))
try
{
global $phpbb_root_path;
include($phpbb_root_path . 'includes/functions.' . $phpEx);
$this->filesystem->phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE);
}
catch (\phpbb\filesystem\exception\filesystem_exception $e)
{
// Do nothing
}
phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE);
$return_value = true;
}