Skip to content

Commit

Permalink
[ticket/15253] Use storage helper methods instead of filesystem methods
Browse files Browse the repository at this point in the history
PHPBB3-15253
  • Loading branch information
rubencm committed Jul 20, 2017
1 parent 21c9b0e commit ecb7953
Show file tree
Hide file tree
Showing 62 changed files with 109 additions and 598 deletions.
3 changes: 1 addition & 2 deletions phpBB/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@

// Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
$phpbb_filesystem = new phpbb\filesystem\filesystem();
$script_path = $phpbb_filesystem->clean_path($script_path);
$script_path = \phpbb\storage\helper::clean_path($script_path);

$url = (($secure) ? 'https://' : 'http://') . $server_name;

Expand Down
3 changes: 0 additions & 3 deletions phpBB/config/default/container/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ imports:
- { resource: services_profilefield.yml }
- { resource: services_report.yml }
- { resource: services_routing.yml }
- { resource: services_storage.yml }
- { resource: services_text_formatter.yml }
- { resource: services_text_reparser.yml }
- { resource: services_twig.yml }
Expand Down Expand Up @@ -106,7 +105,6 @@ services:
file_locator:
class: phpbb\routing\file_locator
arguments:
- '@filesystem'
- '%core.root_path%'

group_helper:
Expand All @@ -130,7 +128,6 @@ services:
class: phpbb\path_helper
arguments:
- '@symfony_request'
- '@filesystem'
- '@request'
- '%core.root_path%'
- '%core.php_ext%'
Expand Down
2 changes: 0 additions & 2 deletions phpBB/config/default/container/services_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ services:

viewonline_helper:
class: phpbb\viewonline_helper
arguments:
- '@filesystem'
1 change: 0 additions & 1 deletion phpBB/config/default/container/services_extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
- '@service_container'
- '@dbal.conn'
- '@config'
- '@filesystem'
- '%tables.ext%'
- '%core.root_path%'
- '%core.php_ext%'
Expand Down
1 change: 0 additions & 1 deletion phpBB/config/default/container/services_routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ services:
- '@router'
- '@symfony_request'
- '@request'
- '@filesystem'
- '%core.root_path%'
- '%core.php_ext%'

Expand Down
16 changes: 0 additions & 16 deletions phpBB/config/default/container/services_storage.yml

This file was deleted.

2 changes: 0 additions & 2 deletions phpBB/config/default/container/services_twig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ services:

template.twig.loader:
class: phpbb\template\twig\loader
arguments:
- '@filesystem'

template.twig.extensions.collection:
class: phpbb\di\service_collection
Expand Down
2 changes: 0 additions & 2 deletions phpBB/config/installer/container/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ services:
file_locator:
class: phpbb\routing\file_locator
arguments:
- '@filesystem'
- '%core.root_path%'

kernel_exception_subscriber:
Expand All @@ -50,7 +49,6 @@ services:
class: phpbb\path_helper
arguments:
- '@symfony_request'
- '@filesystem'
- '@request'
- '%core.root_path%'
- '%core.php_ext%'
Expand Down
2 changes: 1 addition & 1 deletion phpBB/develop/create_schema_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$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/')
->directory('/db/migration/data')
->get_classes();
Expand Down
2 changes: 1 addition & 1 deletion phpBB/develop/mysql_upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

@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/')
->directory('/db/migration/data')
->get_classes();
Expand Down
4 changes: 1 addition & 3 deletions phpBB/includes/bbcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ function bbcode_cache_init()
$phpbb_container->get('path_helper'),
$phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader(
$phpbb_filesystem
)
new \phpbb\template\twig\loader()
),
$phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('user'),
Expand Down
10 changes: 1 addition & 9 deletions phpBB/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3479,15 +3479,7 @@ function phpbb_filter_root_path($errfile)

if (empty($root_path))
{
if ($phpbb_filesystem)
{
$root_path = $phpbb_filesystem->realpath(dirname(__FILE__) . '/../');
}
else
{
$filesystem = new \phpbb\filesystem\filesystem();
$root_path = $filesystem->realpath(dirname(__FILE__) . '/../');
}
$root_path = \phpbb\storage\helper::realpath(dirname(__FILE__) . '/../');
}

return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile);
Expand Down
50 changes: 16 additions & 34 deletions phpBB/includes/functions_compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function phpbb_check_hash($password, $hash)
/**
* Eliminates useless . and .. components from specified path.
*
* Deprecated, use filesystem class instead
* Deprecated, use storage helper class instead
*
* @param string $path Path to clean
* @return string Cleaned path
Expand All @@ -96,36 +96,12 @@ function phpbb_check_hash($password, $hash)
*/
function phpbb_clean_path($path)
{
global $phpbb_path_helper, $phpbb_container;

if (!$phpbb_path_helper && $phpbb_container)
{
/* @var $phpbb_path_helper \phpbb\path_helper */
$phpbb_path_helper = $phpbb_container->get('path_helper');
}
else if (!$phpbb_path_helper)
if (!class_exists('\phpbb\storage\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
);
require($phpbb_root_path . 'phpbb/storage/helper.' . $phpEx);
}

return $phpbb_path_helper->clean_path($path);
return \phpbb\storage\helper::clean_path($path);
}

/**
Expand Down Expand Up @@ -463,25 +439,31 @@ function phpbb_is_writable($file)
* @param string $path Path to check absoluteness of
* @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)
{
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
*
* @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)
{
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);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions phpBB/includes/functions_messenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,7 @@ protected function setup_template()
$phpbb_container->get('path_helper'),
$phpbb_container->getParameter('core.template.cache_path'),
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader(
$phpbb_container->get('filesystem')
),
new \phpbb\template\twig\loader(),
$phpbb_dispatcher,
array()
);
Expand Down
2 changes: 1 addition & 1 deletion phpBB/phpbb/composer/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function __construct($root_path, filesystem $filesystem, request $request
$this->root_path = $root_path;
$this->request = $request;

putenv('COMPOSER_HOME=' . $filesystem->realpath($root_path) . '/store/composer');
putenv('COMPOSER_HOME=' . \phpbb\storage\helper::realpath($root_path) . '/store/composer');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions phpBB/phpbb/di/container_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace phpbb\di;

use phpbb\filesystem\filesystem;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\FileLocator;
Expand Down Expand Up @@ -180,8 +179,7 @@ public function get_container()
$this->register_ext_compiler_pass();
}

$filesystem = new filesystem();
$loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
$loader = new YamlFileLoader($this->container, new FileLocator(\phpbb\storage\helper::realpath($this->get_config_path())));
$loader->load($this->container->getParameter('core.environment') . '/config.yml');

$this->inject_custom_parameters();
Expand Down
3 changes: 1 addition & 2 deletions phpBB/phpbb/di/extension/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public function __construct($config_path)
*/
public function load(array $configs, ContainerBuilder $container)
{
$filesystem = new \phpbb\filesystem\filesystem();
$loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->config_path)));
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($this->config_path)));
$loader->load($container->getParameter('core.environment') . '/container/environment.yml');

$config = $this->getConfiguration($configs, $container);
Expand Down
3 changes: 1 addition & 2 deletions phpBB/phpbb/extension/di/extension_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ protected function load_services(ContainerBuilder $container)

if ($services_directory && $services_file)
{
$filesystem = new \phpbb\filesystem\filesystem();
$loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($services_directory)));
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($services_directory)));
$loader->load($services_file);
}
}
Expand Down
6 changes: 2 additions & 4 deletions phpBB/phpbb/extension/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,20 @@ class manager
* @param ContainerInterface $container A container
* @param \phpbb\db\driver\driver_interface $db A database connection
* @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 $phpbb_root_path Path to the phpbb includes directory.
* @param string $php_ext php file extension, defaults to php
* @param \phpbb\cache\service $cache A cache instance or null
* @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_name = $cache_name;
$this->config = $config;
$this->container = $container;
$this->db = $db;
$this->extension_table = $extension_table;
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;

Expand Down Expand Up @@ -619,7 +617,7 @@ public function is_purged($name)
*/
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)
{
$finder->set_extensions(array_keys($this->all_available()));
Expand Down
Loading

0 comments on commit ecb7953

Please sign in to comment.