Skip to content

Commit

Permalink
[ticket/13697] Moving filesystem related functions to filesystem service
Browse files Browse the repository at this point in the history
 * Moving filesystem service to \phpbb\filesystem namespace
 * Wraping Symfony's Filesystem component
 * Moving filesystem related functions from includes/functions.php
   into \phpbb\filesystem\filesystem
   Functions moved (and deprecated):
     - phpbb_chmod
     - phpbb_is_writable
     - phpbb_is_absolute
     - phpbb_own_realpath
     - phpbb_realpath
 * Adding interface for filesystem service

PHPBB3-13697
  • Loading branch information
CHItA committed Apr 16, 2015
1 parent f86c5d9 commit 4bdef6f
Show file tree
Hide file tree
Showing 82 changed files with 1,860 additions and 658 deletions.
2 changes: 1 addition & 1 deletion phpBB/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

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

$url = (($secure) ? 'https://' : 'http://') . $server_name;
Expand Down
2 changes: 1 addition & 1 deletion phpBB/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"symfony/console": "2.7.*@dev",
"symfony/dependency-injection": "2.7.*@dev",
"symfony/event-dispatcher": "2.7.*@dev",
"symfony/filesystem": "2.7.*@dev",
"symfony/http-kernel": "2.7.*@dev",
"symfony/routing": "2.7.*@dev",
"symfony/security-core": "2.7.*@dev",
Expand All @@ -51,7 +52,6 @@
"symfony/css-selector": "2.7.*@dev",
"symfony/debug": "2.7.*@dev",
"symfony/dom-crawler": "2.7.*@dev",
"symfony/filesystem": "2.7.*@dev",
"symfony/finder": "2.7.*@dev",
"symfony/http-foundation": "2.7.*@dev",
"symfony/process": "2.7.*@dev"
Expand Down
3 changes: 2 additions & 1 deletion phpBB/config/default/container/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ services:
- @cache.driver

filesystem:
class: phpbb\filesystem
class: phpbb\filesystem\filesystem

file_downloader:
class: phpbb\file_downloader
Expand Down Expand Up @@ -159,6 +159,7 @@ services:
router:
class: phpbb\routing\router
arguments:
- @filesystem
- @ext.manager
- %core.root_path%
- %core.php_ext%
Expand Down
1 change: 1 addition & 0 deletions phpBB/config/default/container/services_avatar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ services:
- @config
- %core.root_path%
- %core.php_ext%
- @filesystem
- @path_helper
- @mimetype.guesser
- @cache.driver
Expand Down
1 change: 1 addition & 0 deletions phpBB/config/default/container/services_console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ services:
- @config
- @cache
- @log
- @filesystem
- %core.root_path%
tags:
- { name: console.command }
Expand Down
2 changes: 2 additions & 0 deletions phpBB/config/default/container/services_twig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ services:

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

template.twig.extensions.collection:
class: phpbb\di\service_collection
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 @@ -43,7 +43,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(), $phpbb_root_path);
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $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(), $phpbb_root_path);
$finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path);
$classes = $finder->core_path('phpbb/')
->directory('/db/migration/data')
->get_classes();
Expand Down
18 changes: 15 additions & 3 deletions phpBB/includes/acp/acp_attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ class acp_attachments
/** @var \phpbb\user */
protected $user;

/** @var \phpbb\filesystem\filesystem_interface */
protected $filesystem;

public $id;
public $u_action;
protected $new_config;

function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $phpbb_container;
global $db, $user, $auth, $template, $cache, $phpbb_container, $phpbb_filesystem;
global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log, $request;

$this->id = $id;
Expand All @@ -51,6 +54,7 @@ function main($id, $mode)
$this->template = $template;
$this->user = $user;
$this->phpbb_container = $phpbb_container;
$this->filesystem = $phpbb_filesystem;

$user->add_lang(array('posting', 'viewtopic', 'acp/attachments'));

Expand Down Expand Up @@ -1501,7 +1505,15 @@ function test_upload(&$error, $upload_dir, $create_directory = false)
if (!file_exists($phpbb_root_path . $upload_dir))
{
@mkdir($phpbb_root_path . $upload_dir, 0777);
phpbb_chmod($phpbb_root_path . $upload_dir, CHMOD_READ | CHMOD_WRITE);

try
{
$this->filesystem->phpbb_chmod($phpbb_root_path . $upload_dir, CHMOD_READ | CHMOD_WRITE);
}
catch (\phpbb\filesystem\exception\filesystem_exception $e)
{
// Do nothing
}
}
}

Expand All @@ -1517,7 +1529,7 @@ function test_upload(&$error, $upload_dir, $create_directory = false)
return;
}

if (!phpbb_is_writable($phpbb_root_path . $upload_dir))
if (!$this->filesystem->is_writable($phpbb_root_path . $upload_dir))
{
$error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir);
return;
Expand Down
4 changes: 2 additions & 2 deletions phpBB/includes/acp/acp_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class acp_main
function main($id, $mode)
{
global $config, $db, $cache, $user, $auth, $template, $request, $phpbb_log;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container, $phpbb_dispatcher;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container, $phpbb_dispatcher, $phpbb_filesystem;

// Show restore permissions notice
if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm'))
Expand Down Expand Up @@ -644,7 +644,7 @@ function main($id, $mode)
}
}

if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx))
if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx))
{
// World-Writable? (000x)
$template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002));
Expand Down
6 changes: 4 additions & 2 deletions phpBB/includes/bbcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = fals
*/
function bbcode_cache_init()
{
global $phpbb_root_path, $phpEx, $config, $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_path_helper, $phpbb_container;
global $phpbb_root_path, $phpEx, $config, $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_path_helper, $phpbb_container, $phpbb_filesystem;

if (empty($this->template_filename))
{
Expand All @@ -146,7 +146,9 @@ function bbcode_cache_init()
$phpbb_container,
$phpbb_container->getParameter('core.root_path') . 'cache/',
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader()
new \phpbb\template\twig\loader(
$phpbb_filesystem
)
),
$phpbb_container->getParameter('core.root_path') . 'cache/',
$phpbb_container->get('template.twig.extensions.collection'),
Expand Down
2 changes: 1 addition & 1 deletion phpBB/includes/compatibility_globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
/* @var $symfony_request \phpbb\symfony_request */
$symfony_request = $phpbb_container->get('symfony_request');

/* @var $phpbb_filesystem \phpbb\filesystem */
/* @var $phpbb_filesystem \phpbb\filesystem\filesystem_interface */
$phpbb_filesystem = $phpbb_container->get('filesystem');

/* @var $phpbb_path_helper \phpbb\path_helper */
Expand Down
Loading

0 comments on commit 4bdef6f

Please sign in to comment.