[ticket/15253] Use storage helper methods instead of filesystem methods

PHPBB3-15253
This commit is contained in:
Rubén Calvo 2017-06-26 15:49:31 +02:00
parent 21c9b0eeae
commit ecb79539f4
62 changed files with 109 additions and 598 deletions

View file

@ -65,8 +65,7 @@ if (!defined('PHPBB_INSTALLED'))
// Eliminate . and .. from the path // Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx); require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
$phpbb_filesystem = new phpbb\filesystem\filesystem(); $script_path = \phpbb\storage\helper::clean_path($script_path);
$script_path = $phpbb_filesystem->clean_path($script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name; $url = (($secure) ? 'https://' : 'http://') . $server_name;

View file

@ -25,7 +25,6 @@ imports:
- { resource: services_profilefield.yml } - { resource: services_profilefield.yml }
- { resource: services_report.yml } - { resource: services_report.yml }
- { resource: services_routing.yml } - { resource: services_routing.yml }
- { resource: services_storage.yml }
- { resource: services_text_formatter.yml } - { resource: services_text_formatter.yml }
- { resource: services_text_reparser.yml } - { resource: services_text_reparser.yml }
- { resource: services_twig.yml } - { resource: services_twig.yml }
@ -106,7 +105,6 @@ services:
file_locator: file_locator:
class: phpbb\routing\file_locator class: phpbb\routing\file_locator
arguments: arguments:
- '@filesystem'
- '%core.root_path%' - '%core.root_path%'
group_helper: group_helper:
@ -130,7 +128,6 @@ services:
class: phpbb\path_helper class: phpbb\path_helper
arguments: arguments:
- '@symfony_request' - '@symfony_request'
- '@filesystem'
- '@request' - '@request'
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'

View file

@ -68,5 +68,3 @@ services:
viewonline_helper: viewonline_helper:
class: phpbb\viewonline_helper class: phpbb\viewonline_helper
arguments:
- '@filesystem'

View file

@ -5,7 +5,6 @@ services:
- '@service_container' - '@service_container'
- '@dbal.conn' - '@dbal.conn'
- '@config' - '@config'
- '@filesystem'
- '%tables.ext%' - '%tables.ext%'
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'

View file

@ -23,7 +23,6 @@ services:
- '@router' - '@router'
- '@symfony_request' - '@symfony_request'
- '@request' - '@request'
- '@filesystem'
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'

View file

@ -1,16 +0,0 @@
services:
storage.adapter.avatar:
class: phpbb\storage\adapter\local
arguments:
- '@config'
- '@filesystem'
- '%core.root_path%'
- 'avatar_path'
storage.avatar:
class: phpbb\storage\storage
arguments:
- '@storage.adapter.avatar'
storage.controller:
class: phpbb\storage\controller
arguments:
- '@service_container'

View file

@ -24,8 +24,6 @@ services:
template.twig.loader: template.twig.loader:
class: phpbb\template\twig\loader class: phpbb\template\twig\loader
arguments:
- '@filesystem'
template.twig.extensions.collection: template.twig.extensions.collection:
class: phpbb\di\service_collection class: phpbb\di\service_collection

View file

@ -31,7 +31,6 @@ services:
file_locator: file_locator:
class: phpbb\routing\file_locator class: phpbb\routing\file_locator
arguments: arguments:
- '@filesystem'
- '%core.root_path%' - '%core.root_path%'
kernel_exception_subscriber: kernel_exception_subscriber:
@ -50,7 +49,6 @@ services:
class: phpbb\path_helper class: phpbb\path_helper
arguments: arguments:
- '@symfony_request' - '@symfony_request'
- '@filesystem'
- '@request' - '@request'
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'

View file

@ -44,7 +44,7 @@ require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register(); $phpbb_class_loader->register();
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path); $finder = new \phpbb\finder($phpbb_root_path);
$classes = $finder->core_path('phpbb/') $classes = $finder->core_path('phpbb/')
->directory('/db/migration/data') ->directory('/db/migration/data')
->get_classes(); ->get_classes();

View file

@ -62,7 +62,7 @@ echo "USE $dbname;$newline$newline";
@set_time_limit(0); @set_time_limit(0);
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path); $finder = new \phpbb\finder($phpbb_root_path);
$classes = $finder->core_path('phpbb/') $classes = $finder->core_path('phpbb/')
->directory('/db/migration/data') ->directory('/db/migration/data')
->get_classes(); ->get_classes();

View file

@ -156,9 +156,7 @@ class bbcode
$phpbb_container->get('path_helper'), $phpbb_container->get('path_helper'),
$phpbb_container->getParameter('core.cache_dir'), $phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'), $phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader( new \phpbb\template\twig\loader()
$phpbb_filesystem
)
), ),
$phpbb_container->getParameter('core.cache_dir'), $phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('user'), $phpbb_container->get('user'),

View file

@ -3479,15 +3479,7 @@ function phpbb_filter_root_path($errfile)
if (empty($root_path)) if (empty($root_path))
{ {
if ($phpbb_filesystem) $root_path = \phpbb\storage\helper::realpath(dirname(__FILE__) . '/../');
{
$root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../');
}
else
{
$filesystem = new \phpbb\filesystem\filesystem();
$root_path = $filesystem->realpath(dirname(__FILE__) . '/../');
}
} }
return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile); return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile);

View file

@ -87,7 +87,7 @@ function phpbb_check_hash($password, $hash)
/** /**
* Eliminates useless . and .. components from specified path. * Eliminates useless . and .. components from specified path.
* *
* Deprecated, use filesystem class instead * Deprecated, use storage helper class instead
* *
* @param string $path Path to clean * @param string $path Path to clean
* @return string Cleaned path * @return string Cleaned path
@ -96,36 +96,12 @@ function phpbb_check_hash($password, $hash)
*/ */
function phpbb_clean_path($path) function phpbb_clean_path($path)
{ {
global $phpbb_path_helper, $phpbb_container; if (!class_exists('\phpbb\storage\helper'))
if (!$phpbb_path_helper && $phpbb_container)
{ {
/* @var $phpbb_path_helper \phpbb\path_helper */ require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx);
$phpbb_path_helper = $phpbb_container->get('path_helper');
}
else if (!$phpbb_path_helper)
{
global $phpbb_root_path, $phpEx;
// The container is not yet loaded, use a new instance
if (!class_exists('\phpbb\path_helper'))
{
require($phpbb_root_path . 'phpbb/path_helper.' . $phpEx);
}
$request = new phpbb\request\request();
$phpbb_path_helper = new phpbb\path_helper(
new phpbb\symfony_request(
$request
),
new phpbb\filesystem\filesystem(),
$request,
$phpbb_root_path,
$phpEx
);
} }
return $phpbb_path_helper->clean_path($path); return \phpbb\storage\helper::clean_path($path);
} }
/** /**
@ -463,25 +439,31 @@ function phpbb_is_writable($file)
* @param string $path Path to check absoluteness of * @param string $path Path to check absoluteness of
* @return boolean * @return boolean
* *
* @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::is_absolute_path() instead * @deprecated 3.2.0-dev use \phpbb\storage\helper::is_absolute_path() instead
*/ */
function phpbb_is_absolute($path) function phpbb_is_absolute($path)
{ {
global $phpbb_filesystem; if (!class_exists('\phpbb\storage\helper'))
{
require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx);
}
return $phpbb_filesystem->is_absolute_path($path); return \phpbb\storage\helper::is_absolute_path($path);
} }
/** /**
* A wrapper for realpath * A wrapper for realpath
* *
* @deprecated 3.2.0-dev use \phpbb\filesystem\filesystem::realpath() instead * @deprecated 3.2.0-dev use \phpbb\storage\helper::realpath() instead
*/ */
function phpbb_realpath($path) function phpbb_realpath($path)
{ {
global $phpbb_filesystem; if (!class_exists('\phpbb\storage\helper'))
{
require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx);
}
return $phpbb_filesystem->realpath($path); return \phpbb\storage\helper::realpath($path);
} }
/** /**

View file

@ -699,9 +699,7 @@ class messenger
$phpbb_container->get('path_helper'), $phpbb_container->get('path_helper'),
$phpbb_container->getParameter('core.template.cache_path'), $phpbb_container->getParameter('core.template.cache_path'),
$phpbb_container->get('ext.manager'), $phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader( new \phpbb\template\twig\loader(),
$phpbb_container->get('filesystem')
),
$phpbb_dispatcher, $phpbb_dispatcher,
array() array()
); );

View file

@ -108,7 +108,7 @@ class installer
$this->root_path = $root_path; $this->root_path = $root_path;
$this->request = $request; $this->request = $request;
putenv('COMPOSER_HOME=' . $filesystem->realpath($root_path) . '/store/composer'); putenv('COMPOSER_HOME=' . \phpbb\storage\helper::realpath($root_path) . '/store/composer');
} }
/** /**

View file

@ -13,7 +13,6 @@
namespace phpbb\di; namespace phpbb\di;
use phpbb\filesystem\filesystem;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
@ -180,8 +179,7 @@ class container_builder
$this->register_ext_compiler_pass(); $this->register_ext_compiler_pass();
} }
$filesystem = new filesystem(); $loader = new YamlFileLoader($this->container, new FileLocator(\phpbb\storage\helper::realpath($this->get_config_path())));
$loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
$loader->load($this->container->getParameter('core.environment') . '/config.yml'); $loader->load($this->container->getParameter('core.environment') . '/config.yml');
$this->inject_custom_parameters(); $this->inject_custom_parameters();

View file

@ -53,8 +53,7 @@ class core extends Extension
*/ */
public function load(array $configs, ContainerBuilder $container) public function load(array $configs, ContainerBuilder $container)
{ {
$filesystem = new \phpbb\filesystem\filesystem(); $loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($this->config_path)));
$loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->config_path)));
$loader->load($container->getParameter('core.environment') . '/container/environment.yml'); $loader->load($container->getParameter('core.environment') . '/container/environment.yml');
$config = $this->getConfiguration($configs, $container); $config = $this->getConfiguration($configs, $container);

View file

@ -94,8 +94,7 @@ class extension_base extends Extension
if ($services_directory && $services_file) if ($services_directory && $services_file)
{ {
$filesystem = new \phpbb\filesystem\filesystem(); $loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($services_directory)));
$loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($services_directory)));
$loader->load($services_file); $loader->load($services_file);
} }
} }

View file

@ -40,14 +40,13 @@ class manager
* @param ContainerInterface $container A container * @param ContainerInterface $container A container
* @param \phpbb\db\driver\driver_interface $db A database connection * @param \phpbb\db\driver\driver_interface $db A database connection
* @param \phpbb\config\config $config Config object * @param \phpbb\config\config $config Config object
* @param \phpbb\filesystem\filesystem_interface $filesystem
* @param string $extension_table The name of the table holding extensions * @param string $extension_table The name of the table holding extensions
* @param string $phpbb_root_path Path to the phpbb includes directory. * @param string $phpbb_root_path Path to the phpbb includes directory.
* @param string $php_ext php file extension, defaults to php * @param string $php_ext php file extension, defaults to php
* @param \phpbb\cache\service $cache A cache instance or null * @param \phpbb\cache\service $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext * @param string $cache_name The name of the cache variable, defaults to _ext
*/ */
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\service $cache = null, $cache_name = '_ext') public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\service $cache = null, $cache_name = '_ext')
{ {
$this->cache = $cache; $this->cache = $cache;
$this->cache_name = $cache_name; $this->cache_name = $cache_name;
@ -55,7 +54,6 @@ class manager
$this->container = $container; $this->container = $container;
$this->db = $db; $this->db = $db;
$this->extension_table = $extension_table; $this->extension_table = $extension_table;
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
@ -619,7 +617,7 @@ class manager
*/ */
public function get_finder($use_all_available = false) public function get_finder($use_all_available = false)
{ {
$finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); $finder = new \phpbb\finder($this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
if ($use_all_available) if ($use_all_available)
{ {
$finder->set_extensions(array_keys($this->all_available())); $finder->set_extensions(array_keys($this->all_available()));

View file

@ -162,26 +162,7 @@ class filesystem implements filesystem_interface
*/ */
public function clean_path($path) public function clean_path($path)
{ {
$exploded = explode('/', $path); return \phpbb\storage\helper::clean_path($path);
$filtered = array();
foreach ($exploded as $part)
{
if ($part === '.' && !empty($filtered))
{
continue;
}
if ($part === '..' && !empty($filtered) && $filtered[count($filtered) - 1] !== '.' && $filtered[count($filtered) - 1] !== '..')
{
array_pop($filtered);
}
else
{
$filtered[] = $part;
}
}
$path = implode('/', $filtered);
return $path;
} }
/** /**
@ -227,7 +208,7 @@ class filesystem implements filesystem_interface
*/ */
public function is_absolute_path($path) public function is_absolute_path($path)
{ {
return (isset($path[0]) && $path[0] === '/' || preg_match('#^[a-z]:[/\\\]#i', $path)) ? true : false; return \phpbb\storage\helper::is_absolute_path($path);
} }
/** /**
@ -305,7 +286,7 @@ class filesystem implements filesystem_interface
*/ */
public function make_path_relative($end_path, $start_path) public function make_path_relative($end_path, $start_path)
{ {
return $this->symfony_filesystem->makePathRelative($end_path, $start_path); return \phpbb\storage\helper::make_path_relative($end_path, $start_path);
} }
/** /**
@ -639,6 +620,8 @@ class filesystem implements filesystem_interface
/** /**
* Try to resolve real path when PHP's realpath failes to do so * Try to resolve real path when PHP's realpath failes to do so
* *
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*
* @param string $path * @param string $path
* @return bool|string * @return bool|string
*/ */
@ -764,6 +747,8 @@ class filesystem implements filesystem_interface
/** /**
* Try to resolve symlinks in path * Try to resolve symlinks in path
* *
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*
* @param string $path The path to resolve * @param string $path The path to resolve
* @param string $prefix The path prefix (on windows the drive letter) * @param string $prefix The path prefix (on windows the drive letter)
* @param bool $absolute Whether or not the path is absolute * @param bool $absolute Whether or not the path is absolute
@ -774,143 +759,6 @@ class filesystem implements filesystem_interface
*/ */
protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false) protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false)
{ {
if ($return_array) return \phpbb\storage\helper::resolve_path($path, $prefix, $absolute, $return_array);
{
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
}
trim ($path, '/');
$path_parts = explode('/', $path);
$resolved = array();
$resolved_path = $prefix;
$file_found = false;
foreach ($path_parts as $path_part)
{
if ($file_found)
{
return false;
}
if (empty($path_part) || ($path_part === '.' && ($absolute || !empty($resolved))))
{
continue;
}
else if ($absolute && $path_part === '..')
{
if (empty($resolved))
{
// No directories above root
return false;
}
array_pop($resolved);
$resolved_path = false;
}
else if ($path_part === '..' && !empty($resolved) && !in_array($resolved[count($resolved) - 1], array('.', '..')))
{
array_pop($resolved);
$resolved_path = false;
}
else
{
if ($resolved_path === false)
{
if (empty($resolved))
{
$resolved_path = ($absolute) ? $prefix . '/' . $path_part : $path_part;
}
else
{
$tmp_array = $resolved;
if ($absolute)
{
array_unshift($tmp_array, $prefix);
}
$resolved_path = implode('/', $tmp_array);
}
}
$current_path = $resolved_path . '/' . $path_part;
// Resolve symlinks
if (is_link($current_path))
{
if (!function_exists('readlink'))
{
return false;
}
$link = readlink($current_path);
// Is link has an absolute path in it?
if ($this->is_absolute_path($link))
{
if (defined('PHP_WINDOWS_VERSION_MAJOR'))
{
$prefix = $link[0] . ':';
$link = substr($link, 2);
}
else
{
$prefix = '';
}
$resolved = $this->resolve_path($link, $prefix, true, true);
$absolute = true;
}
else
{
$resolved = $this->resolve_path($resolved_path . '/' . $link, $prefix, $absolute, true);
}
if (!$resolved)
{
return false;
}
$resolved_path = false;
}
else if (is_dir($current_path . '/'))
{
$resolved[] = $path_part;
$resolved_path = $current_path;
}
else if (is_file($current_path))
{
$resolved[] = $path_part;
$resolved_path = $current_path;
$file_found = true;
}
else
{
return false;
}
}
}
// If at the end of the path there were a .. or .
// we need to build the path again.
// Only doing this when a string is expected in return
if ($resolved_path === false && $return_array === false)
{
if (empty($resolved))
{
$resolved_path = ($absolute) ? $prefix . '/' : './';
}
else
{
$tmp_array = $resolved;
if ($absolute)
{
array_unshift($tmp_array, $prefix);
}
$resolved_path = implode('/', $tmp_array);
}
}
return ($return_array) ? $resolved : $resolved_path;
} }
} }

View file

@ -89,6 +89,8 @@ interface filesystem_interface
/** /**
* Eliminates useless . and .. components from specified path. * Eliminates useless . and .. components from specified path.
* *
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*
* @param string $path Path to clean * @param string $path Path to clean
* *
* @return string Cleaned path * @return string Cleaned path
@ -132,6 +134,8 @@ interface filesystem_interface
/** /**
* Checks if a path is absolute or not * Checks if a path is absolute or not
* *
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*
* @param string $path Path to check * @param string $path Path to check
* *
* @return bool true if the path is absolute, false otherwise * @return bool true if the path is absolute, false otherwise
@ -161,6 +165,8 @@ interface filesystem_interface
/** /**
* Given an existing path, convert it to a path relative to a given starting path * Given an existing path, convert it to a path relative to a given starting path
* *
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*
* @param string $end_path Absolute path of target * @param string $end_path Absolute path of target
* @param string $start_path Absolute path where traversal begins * @param string $start_path Absolute path where traversal begins
* *
@ -228,6 +234,8 @@ interface filesystem_interface
/** /**
* A wrapper for PHP's realpath * A wrapper for PHP's realpath
* *
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*
* Try to resolve realpath when PHP's realpath is not available, or * Try to resolve realpath when PHP's realpath is not available, or
* known to be buggy. * known to be buggy.
* *

View file

@ -19,7 +19,6 @@ namespace phpbb;
class finder class finder
{ {
protected $extensions; protected $extensions;
protected $filesystem;
protected $phpbb_root_path; protected $phpbb_root_path;
protected $cache; protected $cache;
protected $php_ext; protected $php_ext;
@ -48,16 +47,14 @@ class finder
/** /**
* Creates a new finder instance with its dependencies * Creates a new finder instance with its dependencies
* *
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem instance
* @param string $phpbb_root_path Path to the phpbb root directory * @param string $phpbb_root_path Path to the phpbb root directory
* @param \phpbb\cache\service $cache A cache instance or null * @param \phpbb\cache\service $cache A cache instance or null
* @param string $php_ext php file extension * @param string $php_ext php file extension
* @param string $cache_name The name of the cache variable, defaults to * @param string $cache_name The name of the cache variable, defaults to
* _ext_finder * _ext_finder
*/ */
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path = '', \phpbb\cache\service $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') public function __construct($phpbb_root_path = '', \phpbb\cache\service $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
{ {
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->cache = $cache; $this->cache = $cache;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
@ -244,7 +241,7 @@ class finder
*/ */
protected function sanitise_directory($directory) protected function sanitise_directory($directory)
{ {
$directory = $this->filesystem->clean_path($directory); $directory = \phpbb\storage\helper::clean_path($directory);
$dir_len = strlen($directory); $dir_len = strlen($directory);
if ($dir_len > 1 && $directory[$dir_len - 1] === '/') if ($dir_len > 1 && $directory[$dir_len - 1] === '/')

View file

@ -329,7 +329,7 @@ class database
// Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
if ($dbms_info['SCHEMA'] === 'sqlite' if ($dbms_info['SCHEMA'] === 'sqlite'
&& stripos($this->filesystem->realpath($dbhost), $this->filesystem->realpath($this->phpbb_root_path) === 0)) && stripos(\phpbb\storage\helper::realpath($dbhost), \phpbb\storage\helper::realpath($this->phpbb_root_path) === 0))
{ {
$errors[] = array( $errors[] = array(
'title' =>'INST_ERR_DB_FORUM_PATH', 'title' =>'INST_ERR_DB_FORUM_PATH',

View file

@ -183,7 +183,7 @@ class create_schema extends \phpbb\install\task_base
include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
} }
$finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); $finder = new \phpbb\finder($this->phpbb_root_path, null, $this->php_ext);
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory(); $factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true); $db_tools = $factory->get($this->db, true);

View file

@ -117,7 +117,7 @@ class create_schema_file extends \phpbb\install\task_base
include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
} }
$finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); $finder = new \phpbb\finder($this->phpbb_root_path, null, $this->php_ext);
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
$factory = new \phpbb\db\tools\factory(); $factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($this->db, true); $db_tools = $factory->get($this->db, true);

View file

@ -21,9 +21,6 @@ class path_helper
/** @var \phpbb\symfony_request */ /** @var \phpbb\symfony_request */
protected $symfony_request; protected $symfony_request;
/** @var \phpbb\filesystem\filesystem_interface */
protected $filesystem;
/** @var \phpbb\request\request_interface */ /** @var \phpbb\request\request_interface */
protected $request; protected $request;
@ -43,16 +40,14 @@ class path_helper
* Constructor * Constructor
* *
* @param \phpbb\symfony_request $symfony_request * @param \phpbb\symfony_request $symfony_request
* @param \phpbb\filesystem\filesystem_interface $filesystem
* @param \phpbb\request\request_interface $request * @param \phpbb\request\request_interface $request
* @param string $phpbb_root_path Relative path to phpBB root * @param string $phpbb_root_path Relative path to phpBB root
* @param string $php_ext PHP file extension * @param string $php_ext PHP file extension
* @param mixed $adm_relative_path Relative path admin path to adm/ root * @param mixed $adm_relative_path Relative path admin path to adm/ root
*/ */
public function __construct(\phpbb\symfony_request $symfony_request, \phpbb\filesystem\filesystem_interface $filesystem, \phpbb\request\request_interface $request, $phpbb_root_path, $php_ext, $adm_relative_path = null) public function __construct(\phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, $phpbb_root_path, $php_ext, $adm_relative_path = null)
{ {
$this->symfony_request = $symfony_request; $this->symfony_request = $symfony_request;
$this->filesystem = $filesystem;
$this->request = $request; $this->request = $request;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
@ -117,7 +112,7 @@ class path_helper
$path = substr($path, 8); $path = substr($path, 8);
} }
return $this->filesystem->clean_path($web_root_path . $path); return \phpbb\storage\helper::clean_path($web_root_path . $path);
} }
return $path; return $path;
@ -163,7 +158,7 @@ class path_helper
// We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result. // We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result.
// Path info (e.g. /foo/bar) // Path info (e.g. /foo/bar)
$path_info = $this->filesystem->clean_path($this->symfony_request->getPathInfo()); $path_info = \phpbb\storage\helper::clean_path($this->symfony_request->getPathInfo());
// Full request URI (e.g. phpBB/app.php/foo/bar) // Full request URI (e.g. phpBB/app.php/foo/bar)
$request_uri = $this->symfony_request->getRequestUri(); $request_uri = $this->symfony_request->getRequestUri();
@ -178,7 +173,7 @@ class path_helper
*/ */
if ($path_info === '/' && preg_match('/app\.' . $this->php_ext . '\/$/', $request_uri)) if ($path_info === '/' && preg_match('/app\.' . $this->php_ext . '\/$/', $request_uri))
{ {
return $this->web_root_path = $this->filesystem->clean_path('./../' . $this->phpbb_root_path); return $this->web_root_path = \phpbb\storage\helper::clean_path('./../' . $this->phpbb_root_path);
} }
/* /*
@ -235,7 +230,7 @@ class path_helper
} }
// Prepend ../ to the phpbb_root_path as many times as / exists in path_info // Prepend ../ to the phpbb_root_path as many times as / exists in path_info
$this->web_root_path = $this->filesystem->clean_path( $this->web_root_path = \phpbb\storage\helper::clean_path(
'./' . str_repeat('../', $corrections) . $this->phpbb_root_path './' . str_repeat('../', $corrections) . $this->phpbb_root_path
); );
return $this->web_root_path; return $this->web_root_path;
@ -326,7 +321,7 @@ class path_helper
// Add length of URL delimiter to position // Add length of URL delimiter to position
$path = substr($url, $delimiter_position + 3); $path = substr($url, $delimiter_position + 3);
return $scheme . $this->filesystem->clean_path($path); return $scheme . \phpbb\storage\helper::clean_path($path);
} }
/** /**

View file

@ -13,19 +13,18 @@
namespace phpbb\routing; namespace phpbb\routing;
use phpbb\filesystem\filesystem_interface;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
class file_locator extends FileLocator class file_locator extends FileLocator
{ {
public function __construct(filesystem_interface $filesystem, $paths = []) public function __construct($paths = [])
{ {
$paths = (array) $paths; $paths = (array) $paths;
$absolute_paths = []; $absolute_paths = [];
foreach ($paths as $path) foreach ($paths as $path)
{ {
$absolute_paths[] = $filesystem->realpath($path); $absolute_paths[] = \phpbb\storage\helper::realpath($path);
} }
parent::__construct($absolute_paths); parent::__construct($absolute_paths);

View file

@ -43,11 +43,6 @@ class helper
*/ */
protected $request; protected $request;
/**
* @var \phpbb\filesystem The filesystem object
*/
protected $filesystem;
/** /**
* phpBB root path * phpBB root path
* @var string * @var string
@ -67,17 +62,15 @@ class helper
* @param \phpbb\routing\router $router phpBB router * @param \phpbb\routing\router $router phpBB router
* @param \phpbb\symfony_request $symfony_request Symfony Request object * @param \phpbb\symfony_request $symfony_request Symfony Request object
* @param \phpbb\request\request_interface $request phpBB request object * @param \phpbb\request\request_interface $request phpBB request object
* @param \phpbb\filesystem\filesystem $filesystem The filesystem object
* @param string $phpbb_root_path phpBB root path * @param string $phpbb_root_path phpBB root path
* @param string $php_ext PHP file extension * @param string $php_ext PHP file extension
*/ */
public function __construct(\phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem\filesystem $filesystem, $phpbb_root_path, $php_ext) public function __construct(\phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, $phpbb_root_path, $php_ext)
{ {
$this->config = $config; $this->config = $config;
$this->router = $router; $this->router = $router;
$this->symfony_request = $symfony_request; $this->symfony_request = $symfony_request;
$this->request = $request; $this->request = $request;
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
} }
@ -140,7 +133,7 @@ class helper
} }
} }
$base_url = $this->request->escape($this->filesystem->clean_path($base_url), true); $base_url = $this->request->escape(\phpbb\storage\helper::clean_path($base_url), true);
$context->setBaseUrl($base_url); $context->setBaseUrl($base_url);

View file

@ -38,7 +38,7 @@ class session
*/ */
static function extract_current_page($root_path) static function extract_current_page($root_path)
{ {
global $request, $symfony_request, $phpbb_filesystem; global $request, $symfony_request;
$page_array = array(); $page_array = array();
@ -85,15 +85,15 @@ class session
$page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name); $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name);
$page_name = urlencode(htmlspecialchars($page_name)); $page_name = urlencode(htmlspecialchars($page_name));
$symfony_request_path = $phpbb_filesystem->clean_path($symfony_request->getPathInfo()); $symfony_request_path = \phpbb\storage\helper::clean_path($symfony_request->getPathInfo());
if ($symfony_request_path !== '/') if ($symfony_request_path !== '/')
{ {
$page_name .= str_replace('%2F', '/', urlencode($symfony_request_path)); $page_name .= str_replace('%2F', '/', urlencode($symfony_request_path));
} }
// current directory within the phpBB root (for example: adm) // current directory within the phpBB root (for example: adm)
$root_dirs = explode('/', str_replace('\\', '/', $phpbb_filesystem->realpath($root_path))); $root_dirs = explode('/', str_replace('\\', '/', \phpbb\storage\helper::realpath($root_path)));
$page_dirs = explode('/', str_replace('\\', '/', $phpbb_filesystem->realpath('./'))); $page_dirs = explode('/', str_replace('\\', '/', \phpbb\storage\helper::realpath('./')));
$intersection = array_intersect_assoc($root_dirs, $page_dirs); $intersection = array_intersect_assoc($root_dirs, $page_dirs);
$root_dirs = array_diff_assoc($root_dirs, $intersection); $root_dirs = array_diff_assoc($root_dirs, $intersection);

View file

@ -20,20 +20,15 @@ class asset
/** @var \phpbb\path_helper **/ /** @var \phpbb\path_helper **/
protected $path_helper; protected $path_helper;
/** @var \phpbb\filesystem\filesystem */
protected $filesystem;
/** /**
* Constructor * Constructor
* *
* @param string $url URL * @param string $url URL
* @param \phpbb\path_helper $path_helper Path helper object * @param \phpbb\path_helper $path_helper Path helper object
* @param \phpbb\filesystem\filesystem $filesystem
*/ */
public function __construct($url, \phpbb\path_helper $path_helper, \phpbb\filesystem\filesystem $filesystem) public function __construct($url, \phpbb\path_helper $path_helper)
{ {
$this->path_helper = $path_helper; $this->path_helper = $path_helper;
$this->filesystem = $filesystem;
$this->set_url($url); $this->set_url($url);
} }
@ -158,7 +153,7 @@ class asset
public function set_path($path, $urlencode = false) public function set_path($path, $urlencode = false)
{ {
// Since 1.7.0 Twig returns the real path of the file. We need it to be relative. // Since 1.7.0 Twig returns the real path of the file. We need it to be relative.
$real_root_path = $this->filesystem->realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; $real_root_path = \phpbb\storage\helper::realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR;
// If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path
if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path)
@ -168,7 +163,7 @@ class asset
else else
{ {
// Else we make the path relative to the current working directory // Else we make the path relative to the current working directory
$real_root_path = $this->filesystem->realpath('.') . DIRECTORY_SEPARATOR; $real_root_path = \phpbb\storage\helper::realpath('.') . DIRECTORY_SEPARATOR;
if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path)
{ {
$path = str_replace('\\', '/', substr($path, strlen($real_root_path))); $path = str_replace('\\', '/', substr($path, strlen($real_root_path)));

View file

@ -20,24 +20,6 @@ class loader extends \Twig_Loader_Filesystem
{ {
protected $safe_directories = array(); protected $safe_directories = array();
/**
* @var \phpbb\filesystem\filesystem_interface
*/
protected $filesystem;
/**
* Constructor
*
* @param \phpbb\filesystem\filesystem_interface $filesystem
* @param string|array $paths
*/
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $paths = array())
{
$this->filesystem = $filesystem;
parent::__construct($paths, $this->filesystem->realpath(dirname(__FILE__)));
}
/** /**
* Set safe directories * Set safe directories
* *
@ -67,7 +49,7 @@ class loader extends \Twig_Loader_Filesystem
*/ */
public function addSafeDirectory($directory) public function addSafeDirectory($directory)
{ {
$directory = $this->filesystem->realpath($directory); $directory = \phpbb\storage\helper::realpath($directory);
if ($directory !== false) if ($directory !== false)
{ {
@ -107,7 +89,7 @@ class loader extends \Twig_Loader_Filesystem
*/ */
public function addPath($path, $namespace = self::MAIN_NAMESPACE) public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{ {
return parent::addPath($this->filesystem->realpath($path), $namespace); return parent::addPath(\phpbb\storage\helper::realpath($path), $namespace);
} }
/** /**
@ -147,7 +129,7 @@ class loader extends \Twig_Loader_Filesystem
// can now check if we're within a "safe" directory // can now check if we're within a "safe" directory
// Find the real path of the directory the file is in // Find the real path of the directory the file is in
$directory = $this->filesystem->realpath(dirname($file)); $directory = \phpbb\storage\helper::realpath(dirname($file));
if ($directory === false) if ($directory === false)
{ {

View file

@ -18,15 +18,11 @@ namespace phpbb;
*/ */
class viewonline_helper class viewonline_helper
{ {
/** @var \phpbb\filesystem\filesystem_interface */
protected $filesystem;
/** /**
* @param \phpbb\filesystem\filesystem_interface $filesystem phpBB's filesystem service *
*/ */
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem) public function __construct()
{ {
$this->filesystem = $filesystem;
} }
/** /**
@ -37,7 +33,7 @@ class viewonline_helper
*/ */
public function get_user_page($session_page) public function get_user_page($session_page)
{ {
$session_page = $this->filesystem->clean_path($session_page); $session_page = \phpbb\storage\helper::clean_path($session_page);
if (strpos($session_page, './') === 0) if (strpos($session_page, './') === 0)
{ {
$session_page = substr($session_page, 2); $session_page = substr($session_page, 2);

View file

@ -44,7 +44,6 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
$filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx

View file

@ -97,7 +97,6 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
$mock_router, $mock_router,
new \phpbb\symfony_request($request), new \phpbb\symfony_request($request),
$request, $request,
new \phpbb\filesystem\filesystem(),
$phpbb_root_path, $phpbb_root_path,
$pathEx $pathEx
); );

View file

@ -73,7 +73,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$mock_router, $mock_router,
new \phpbb\symfony_request($request), new \phpbb\symfony_request($request),
$request, $request,
new \phpbb\filesystem\filesystem(),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
); );
@ -147,7 +146,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$mock_router, $mock_router,
new \phpbb\symfony_request($request), new \phpbb\symfony_request($request),
$request, $request,
new \phpbb\filesystem\filesystem(),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
); );
@ -188,7 +186,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$mock_router, $mock_router,
new \phpbb\symfony_request($request), new \phpbb\symfony_request($request),
$request, $request,
new \phpbb\filesystem\filesystem(),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
); );

View file

@ -91,7 +91,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem();
$this->phpbb_path_helper = new \phpbb\path_helper( $this->phpbb_path_helper = new \phpbb\path_helper(
$this->symfony_request, $this->symfony_request,
$this->filesystem,
$this->request, $this->request,
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
@ -106,7 +105,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$container->setParameter('core.environment', PHPBB_ENVIRONMENT); $container->setParameter('core.environment', PHPBB_ENVIRONMENT);
$cache_path = $phpbb_root_path . 'cache/twig'; $cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader($this->filesystem, ''); $loader = new \phpbb\template\twig\loader('');
$twig = new \phpbb\template\twig\environment( $twig = new \phpbb\template\twig\environment(
$this->config, $this->config,
$this->filesystem, $this->filesystem,
@ -137,7 +136,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
); );
$loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(
new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') new \phpbb\routing\file_locator(dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
$this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
@ -185,7 +184,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
} }
@ -229,7 +228,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
} }
@ -273,7 +272,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
} }
@ -317,7 +316,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
} }
@ -361,7 +360,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
} }
@ -405,7 +404,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
} }
@ -446,7 +445,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
} }
@ -490,7 +489,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{ {
$this->config = new \phpbb\config\config(['enable_mod_rewrite' => '1']); $this->config = new \phpbb\config\config(['enable_mod_rewrite' => '1']);
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
} }
@ -522,7 +521,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
'server_protocol' => $server_protocol, 'server_protocol' => $server_protocol,
)); ));
$this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper);
static::assertEquals($expected, $this->helper->route('controller1', array(), false, false, $type)); static::assertEquals($expected, $this->helper->route('controller1', array(), false, false, $type));
} }

View file

@ -45,7 +45,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
$container->setParameter('core.environment', PHPBB_ENVIRONMENT); $container->setParameter('core.environment', PHPBB_ENVIRONMENT);
$loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(
new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') new \phpbb\routing\file_locator(dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
$router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php');

View file

@ -97,7 +97,6 @@ class phpbb_cron_manager_test extends \phpbb_test_case
$mock_router, $mock_router,
new \phpbb\symfony_request($request), new \phpbb\symfony_request($request),
$request, $request,
new \phpbb\filesystem\filesystem(),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
); );

View file

@ -67,7 +67,6 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$container, $container,
$this->db, $this->db,
$this->config, $this->config,
new phpbb\filesystem\filesystem(),
'phpbb_ext', 'phpbb_ext',
dirname(__FILE__) . '/../../phpBB/', dirname(__FILE__) . '/../../phpBB/',
'php', 'php',

View file

@ -25,8 +25,7 @@ class extension extends extension_base
{ {
protected function load_services(ContainerBuilder $container) protected function load_services(ContainerBuilder $container)
{ {
$filesystem = new \phpbb\filesystem\filesystem(); $loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($this->ext_path)));
$loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->ext_path)));
$loader->load('environment.yml'); $loader->load('environment.yml');
} }
} }

View file

@ -39,7 +39,6 @@ class phpbb_email_parsing_test extends phpbb_test_case
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem();
$phpbb_path_helper = new \phpbb\path_helper( $phpbb_path_helper = new \phpbb\path_helper(
$symfony_request, $symfony_request,
$filesystem,
$request, $request,
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
@ -80,7 +79,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$phpbb_path_helper, $phpbb_path_helper,
$cache_path, $cache_path,
null, null,
new \phpbb\template\twig\loader($filesystem, ''), new \phpbb\template\twig\loader(''),
new \phpbb\event\dispatcher($phpbb_container), new \phpbb\event\dispatcher($phpbb_container),
array( array(
'cache' => false, 'cache' => false,

View file

@ -243,7 +243,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
public function test_get_classes_create_cache() public function test_get_classes_create_cache()
{ {
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); $finder = new \phpbb\finder(dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name');
$finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $finder->set_extensions(array_keys($this->extension_manager->all_enabled()));
$files = $finder->suffix('_class.php')->get_files(); $files = $finder->suffix('_class.php')->get_files();
@ -283,7 +283,6 @@ class phpbb_extension_finder_test extends phpbb_test_case
); );
$finder = new \phpbb\finder( $finder = new \phpbb\finder(
new \phpbb\filesystem\filesystem(),
dirname(__FILE__) . '/', dirname(__FILE__) . '/',
new phpbb_mock_cache(array( new phpbb_mock_cache(array(
'_ext_finder' => array( '_ext_finder' => array(

View file

@ -176,7 +176,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$container, $container,
$db, $db,
$config, $config,
new \phpbb\filesystem\filesystem(),
'phpbb_ext', 'phpbb_ext',
dirname(__FILE__) . '/', dirname(__FILE__) . '/',
$php_ext, $php_ext,

View file

@ -52,13 +52,12 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$cache_path = $this->phpbb_root_path . 'cache/twig'; $cache_path = $this->phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $loader = new \phpbb\template\twig\loader('');
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem();
$phpbb_path_helper = new \phpbb\path_helper( $phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
$filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path, $this->phpbb_root_path,
$this->phpEx $this->phpEx
@ -97,7 +96,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$container, $container,
$this->db, $this->db,
$this->config, $this->config,
new \phpbb\filesystem\filesystem(),
'phpbb_ext', 'phpbb_ext',
$this->phpbb_root_path, $this->phpbb_root_path,
$this->phpEx, $this->phpEx,

View file

@ -1,54 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class phpbb_filesystem_clean_path_test extends phpbb_test_case
{
protected $filesystem;
public function setUp()
{
parent::setUp();
$this->filesystem = new \phpbb\filesystem\filesystem();
}
public function clean_path_data()
{
return array(
array('foo', 'foo'),
array('foo/bar', 'foo/bar'),
array('foo/bar/', 'foo/bar/'),
array('foo/./bar', 'foo/bar'),
array('foo/./././bar', 'foo/bar'),
array('foo/bar/.', 'foo/bar'),
array('./foo/bar', './foo/bar'),
array('../foo/bar', '../foo/bar'),
array('./../foo/bar', './../foo/bar'),
array('././../foo/bar', './../foo/bar'),
array('one/two/three', 'one/two/three'),
array('one/two/../three', 'one/three'),
array('one/../two/three', 'two/three'),
array('one/two/..', 'one'),
array('one/two/../', 'one/'),
array('one/two/../three/../four', 'one/four'),
array('one/two/three/../../four', 'one/four'),
);
}
/**
* @dataProvider clean_path_data
*/
public function test_clean_path($input, $expected)
{
$this->assertEquals($expected, $this->filesystem->clean_path($input));
}
}

View file

@ -1,68 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class phpbb_filesystem_is_absolute_test extends phpbb_test_case
{
/** @var \phpbb\filesystem\filesystem_interface */
protected $filesystem;
public function setUp()
{
parent::setUp();
$this->filesystem = new \phpbb\filesystem\filesystem();
}
static public function is_absolute_data()
{
return array(
// Empty
array('', false),
// Absolute unix style
array('/etc/phpbb', true),
// Unix does not support \ so that is not an absolute path
array('\etc\phpbb', false),
// Absolute windows style
array('c:\windows', true),
array('C:\Windows', true),
array('c:/windows', true),
array('C:/Windows', true),
// Executable
array('etc/phpbb', false),
array('explorer.exe', false),
// Relative subdir
array('Windows\System32', false),
array('Windows\System32\explorer.exe', false),
array('Windows/System32', false),
array('Windows/System32/explorer.exe', false),
// Relative updir
array('..\Windows\System32', false),
array('..\Windows\System32\explorer.exe', false),
array('../Windows/System32', false),
array('../Windows/System32/explorer.exe', false),
);
}
/**
* @dataProvider is_absolute_data
*/
public function test_is_absolute($path, $expected)
{
$this->assertEquals($expected, $this->filesystem->is_absolute_path($path));
}
}

View file

@ -1,90 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class phpbb_filesystem_realpath_test extends phpbb_test_case
{
static protected $filesystem_own_realpath;
/** @var \phpbb\filesystem\filesystem_interface */
protected $filesystem;
static public function setUpBeforeClass()
{
parent::setUpBeforeClass();
$reflection_class = new ReflectionClass('\phpbb\filesystem\filesystem');
self::$filesystem_own_realpath = $reflection_class->getMethod('phpbb_own_realpath');
self::$filesystem_own_realpath->setAccessible(true);
}
public function setUp()
{
parent::setUp();
$this->filesystem = new \phpbb\filesystem\filesystem();
}
public function realpath_resolve_absolute_without_symlinks_data()
{
return array(
// Constant data
array(__DIR__, __DIR__),
array(__DIR__ . '/../filesystem/../filesystem', __DIR__),
array(__DIR__ . '/././', __DIR__),
array(__DIR__ . '/non_existent', false),
array(__FILE__, __FILE__),
array(__FILE__ . '../', false),
);
}
public function realpath_resolve_relative_without_symlinks_data()
{
if (!function_exists('getcwd'))
{
return array();
}
$filesystem = new \phpbb\filesystem\filesystem();
$relative_path = $filesystem->make_path_relative(__DIR__, getcwd());
return array(
array($relative_path, __DIR__),
array($relative_path . '../filesystem/../filesystem', __DIR__),
array($relative_path . '././', __DIR__),
array($relative_path . 'realpath_test.php', __FILE__),
);
}
/**
* @dataProvider realpath_resolve_absolute_without_symlinks_data
*/
public function test_realpath_absolute_without_links($path, $expected)
{
$this->assertEquals($expected, self::$filesystem_own_realpath->invoke($this->filesystem, $path));
}
/**
* @dataProvider realpath_resolve_relative_without_symlinks_data
*/
public function test_realpath_relative_without_links($path, $expected)
{
if (!function_exists('getcwd'))
{
$this->markTestSkipped('phpbb_own_realpath() cannot be tested with relative paths: getcwd is not available.');
}
$this->assertEquals($expected, self::$filesystem_own_realpath->invoke($this->filesystem, $path));
}
}

View file

@ -27,7 +27,6 @@ class phpbb_build_url_test extends phpbb_test_case
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
new \phpbb\filesystem\filesystem(),
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
'php' 'php'

View file

@ -39,12 +39,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$filesystem = new \phpbb\filesystem\filesystem();
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
$loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(
new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') new \phpbb\routing\file_locator(dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager);
$router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
@ -58,7 +57,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$request $request
); );
$this->routing_helper = new \phpbb\routing\helper($this->config, $router, $symfony_request, $request, $filesystem, '', 'php'); $this->routing_helper = new \phpbb\routing\helper($this->config, $router, $symfony_request, $request, '', 'php');
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $symfony_request, $request, $this->routing_helper); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $symfony_request, $request, $this->routing_helper);
$this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher);
} }

View file

@ -21,14 +21,12 @@ class phpbb_path_helper_test extends phpbb_test_case
{ {
parent::setUp(); parent::setUp();
$filesystem = new \phpbb\filesystem\filesystem(); $this->set_phpbb_root_path();
$this->set_phpbb_root_path($filesystem);
$this->path_helper = new \phpbb\path_helper( $this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
new \phpbb\filesystem\filesystem(),
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path, $this->phpbb_root_path,
'php' 'php'
@ -43,9 +41,9 @@ class phpbb_path_helper_test extends phpbb_test_case
* any time we wish to use it in one of these functions (and * any time we wish to use it in one of these functions (and
* also in general for everything else) * also in general for everything else)
*/ */
public function set_phpbb_root_path($filesystem) public function set_phpbb_root_path()
{ {
$this->phpbb_root_path = $filesystem->clean_path(dirname(__FILE__) . '/../../phpBB/'); $this->phpbb_root_path = \phpbb\storage\helper::clean_path(dirname(__FILE__) . '/../../phpBB/');
} }
public function test_get_web_root_path() public function test_get_web_root_path()
@ -56,8 +54,7 @@ class phpbb_path_helper_test extends phpbb_test_case
public function basic_update_web_root_path_data() public function basic_update_web_root_path_data()
{ {
$filesystem = new \phpbb\filesystem\filesystem(); $this->set_phpbb_root_path();
$this->set_phpbb_root_path($filesystem);
return array( return array(
array( array(
@ -75,7 +72,7 @@ class phpbb_path_helper_test extends phpbb_test_case
), ),
array( array(
$this->phpbb_root_path . $this->phpbb_root_path . 'test.php', $this->phpbb_root_path . $this->phpbb_root_path . 'test.php',
$filesystem->clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'), \phpbb\storage\helper::clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'),
), ),
); );
} }
@ -90,7 +87,7 @@ class phpbb_path_helper_test extends phpbb_test_case
public function update_web_root_path_data() public function update_web_root_path_data()
{ {
$this->set_phpbb_root_path(new \phpbb\filesystem\filesystem()); $this->set_phpbb_root_path();
return array( return array(
array( array(
@ -195,7 +192,6 @@ class phpbb_path_helper_test extends phpbb_test_case
$path_helper = new \phpbb\path_helper( $path_helper = new \phpbb\path_helper(
$symfony_request, $symfony_request,
new \phpbb\filesystem\filesystem(),
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path, $this->phpbb_root_path,
'php' 'php'

View file

@ -66,7 +66,6 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
new \phpbb\filesystem\filesystem(),
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path, $this->phpbb_root_path,
'php' 'php'

View file

@ -39,9 +39,8 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{ {
global $phpbb_root_path; global $phpbb_root_path;
$filesystem = new \phpbb\filesystem\filesystem();
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc'; $path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
$this->assertTrue($filesystem->is_absolute_path($path_to_php)); $this->assertTrue(\phpbb\storage\helper::is_absolute_path($path_to_php));
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->"; $template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
$cache_dir = $phpbb_root_path . 'cache/'; $cache_dir = $phpbb_root_path . 'cache/';

View file

@ -39,7 +39,6 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
$filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
@ -59,7 +58,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig'; $cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $loader = new \phpbb\template\twig\loader('');
$twig = new \phpbb\template\twig\environment( $twig = new \phpbb\template\twig\environment(
$config, $config,
$filesystem, $filesystem,

View file

@ -144,7 +144,6 @@ Zeta test event in all',
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
new \phpbb\filesystem\filesystem(),
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
@ -153,7 +152,7 @@ Zeta test event in all',
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig'; $cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $loader = new \phpbb\template\twig\loader('');
$twig = new \phpbb\template\twig\environment( $twig = new \phpbb\template\twig\environment(
$config, $config,
$filesystem, $filesystem,

View file

@ -34,7 +34,6 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
$filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
@ -45,7 +44,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig'; $cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $loader = new \phpbb\template\twig\loader('');
$twig = new \phpbb\template\twig\environment( $twig = new \phpbb\template\twig\environment(
$config, $config,
$filesystem, $filesystem,

View file

@ -86,8 +86,12 @@ class phpbb_template_template_test_case extends phpbb_test_case
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
<<<<<<< HEAD
$filesystem, $filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
=======
$this->getMock('\phpbb\request\request'),
>>>>>>> [ticket/15253] Use storage helper methods instead of filesystem methods
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
); );
@ -97,7 +101,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig'; $cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $loader = new \phpbb\template\twig\loader('');
$twig = new \phpbb\template\twig\environment( $twig = new \phpbb\template\twig\environment(
$config, $config,
$filesystem, $filesystem,

View file

@ -28,7 +28,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
), ),
$filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx
@ -40,7 +39,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$container = new phpbb_mock_container_builder(); $container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig'; $cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context(); $context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); $loader = new \phpbb\template\twig\loader('');
$twig = new \phpbb\template\twig\environment( $twig = new \phpbb\template\twig\environment(
$config, $config,
$filesystem, $filesystem,

View file

@ -58,7 +58,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$setup_extensions = static::setup_extensions(); $setup_extensions = static::setup_extensions();
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); $finder = new \phpbb\finder($phpbb_root_path, null, $phpEx);
$finder->core_path('phpbb/db/migration/data/'); $finder->core_path('phpbb/db/migration/data/');
if (!empty($setup_extensions)) if (!empty($setup_extensions))
{ {

View file

@ -366,7 +366,7 @@ class phpbb_database_test_connection_manager
{ {
global $phpbb_root_path, $phpEx, $table_prefix; global $phpbb_root_path, $phpEx, $table_prefix;
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); $finder = new \phpbb\finder($phpbb_root_path, null, $phpEx);
$classes = $finder->core_path('phpbb/db/migration/data/') $classes = $finder->core_path('phpbb/db/migration/data/')
->get_classes(); ->get_classes();

View file

@ -259,7 +259,6 @@ class phpbb_functional_test_case extends phpbb_test_case
$container, $container,
$db, $db,
$config, $config,
new phpbb\filesystem\filesystem(),
self::$config['table_prefix'] . 'ext', self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/', dirname(__FILE__) . '/',
$phpEx, $phpEx,

View file

@ -29,14 +29,12 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case
{ {
parent::setUp(); parent::setUp();
global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $request, $phpbb_root_path, $phpEx; global $symfony_request, $phpbb_path_helper, $request, $phpbb_root_path, $phpEx;
$symfony_request = new \phpbb\symfony_request( $symfony_request = new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()
); );
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
$phpbb_path_helper = new \phpbb\path_helper( $phpbb_path_helper = new \phpbb\path_helper(
$symfony_request, $symfony_request,
$phpbb_filesystem,
$this->createMock('\phpbb\request\request'), $this->createMock('\phpbb\request\request'),
$phpbb_root_path, $phpbb_root_path,
$phpEx $phpEx

View file

@ -382,7 +382,6 @@ class phpbb_ui_test_case extends phpbb_test_case
$container, $container,
$db, $db,
$config, $config,
new phpbb\filesystem(),
$user, $user,
self::$config['table_prefix'] . 'ext', self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/', dirname(__FILE__) . '/',