[ticket/15311] Use cache directory if can't use system temp

PHPBB3-15311
This commit is contained in:
Rubén Calvo 2017-10-23 17:02:05 +02:00
parent e8a70dcb24
commit 01a8487244
46 changed files with 145 additions and 57 deletions

View file

@ -34,6 +34,7 @@ services:
class: phpbb\db\extractor\mssql_extractor class: phpbb\db\extractor\mssql_extractor
shared: false shared: false
arguments: arguments:
- '@filesystem'
- '@request' - '@request'
- '@dbal.conn.driver' - '@dbal.conn.driver'
@ -41,6 +42,7 @@ services:
class: phpbb\db\extractor\mysql_extractor class: phpbb\db\extractor\mysql_extractor
shared: false shared: false
arguments: arguments:
- '@filesystem'
- '@request' - '@request'
- '@dbal.conn.driver' - '@dbal.conn.driver'
@ -48,6 +50,7 @@ services:
class: phpbb\db\extractor\oracle_extractor class: phpbb\db\extractor\oracle_extractor
shared: false shared: false
arguments: arguments:
- '@filesystem'
- '@request' - '@request'
- '@dbal.conn.driver' - '@dbal.conn.driver'
@ -55,6 +58,7 @@ services:
class: phpbb\db\extractor\postgres_extractor class: phpbb\db\extractor\postgres_extractor
shared: false shared: false
arguments: arguments:
- '@filesystem'
- '@request' - '@request'
- '@dbal.conn.driver' - '@dbal.conn.driver'
@ -62,5 +66,6 @@ services:
class: phpbb\db\extractor\sqlite3_extractor class: phpbb\db\extractor\sqlite3_extractor
shared: false shared: false
arguments: arguments:
- '@filesystem'
- '@request' - '@request'
- '@dbal.conn.driver' - '@dbal.conn.driver'

View file

@ -71,6 +71,7 @@ services:
arguments: arguments:
- '@config' - '@config'
- '@files.factory' - '@files.factory'
- '@filesystem'
- '@language' - '@language'
- '@php_ini' - '@php_ini'
- '@request' - '@request'
@ -82,6 +83,7 @@ services:
arguments: arguments:
- '@config' - '@config'
- '@files.factory' - '@files.factory'
- '@filesystem'
- '@language' - '@language'
- '@php_ini' - '@php_ini'
- '@request' - '@request'

View file

@ -1,3 +1,8 @@
parameters:
core.filesystem.cache_temp_dir: '%core.cache_dir%tmp/'
services: services:
filesystem: filesystem:
class: phpbb\filesystem\filesystem class: phpbb\filesystem\filesystem
arguments:
- '%core.filesystem.cache_temp_dir%'

View file

@ -21,8 +21,9 @@ if (!defined('IN_PHPBB'))
class acp_database class acp_database
{ {
var $db_tools; protected $db_tools;
var $u_action; protected $filesystem;
public $u_action;
function main($id, $mode) function main($id, $mode)
{ {
@ -30,6 +31,7 @@ class acp_database
global $phpbb_root_path, $phpbb_container, $phpbb_log, $table_prefix; global $phpbb_root_path, $phpbb_container, $phpbb_log, $table_prefix;
$this->db_tools = $phpbb_container->get('dbal.tools'); $this->db_tools = $phpbb_container->get('dbal.tools');
$this->filesystem = $phpbb_container->get('filesystem');
$storage = $phpbb_container->get('storage.backup'); $storage = $phpbb_container->get('storage.backup');
$user->add_lang('acp/database'); $user->add_lang('acp/database');
@ -172,7 +174,9 @@ class acp_database
$file = $filename . $ext; $file = $filename . $ext;
// Copy to storage using streams // Copy to storage using streams
$fp = fopen(sys_get_temp_dir() . '/' . $file, 'rb'); $temp_dir = $this->filesystem->get_temp_dir();
$fp = fopen($temp_dir . '/' . $file, 'rb');
if ($fp === false) if ($fp === false)
{ {
@ -184,7 +188,7 @@ class acp_database
fclose($fp); fclose($fp);
// Remove file from tmp // Remove file from tmp
@unlink(sys_get_temp_dir() . '/' . $file); @unlink($temp_dir . '/' . $file);
// Save to database // Save to database
$sql = "INSERT INTO " . $table_prefix . "backups (filename) $sql = "INSERT INTO " . $table_prefix . "backups (filename)
@ -343,7 +347,7 @@ class acp_database
} }
// Copy file to temp folder to decompress it // Copy file to temp folder to decompress it
$temp_file_name = sys_get_temp_dir() . '/' . $file_name; $temp_file_name = $this->filesystem->get_temp_dir() . '/' . $file_name;
try try
{ {

View file

@ -215,7 +215,7 @@ class compress_zip extends compress
global $phpbb_filesystem; global $phpbb_filesystem;
$this->fp = @fopen($file, $mode . 'b'); $this->fp = @fopen($file, $mode . 'b');
$this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem(); $this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem('');
if (!$this->fp) if (!$this->fp)
{ {
@ -582,7 +582,7 @@ class compress_tar extends compress
$this->type = &$type; $this->type = &$type;
$this->open(); $this->open();
$this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem(); $this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem('');
} }
/** /**

View file

@ -35,7 +35,7 @@ class file extends \phpbb\cache\driver\base
global $phpbb_container; global $phpbb_container;
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir'); $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir');
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
if (!is_dir($this->cache_dir)) if (!is_dir($this->cache_dir))
{ {

View file

@ -402,7 +402,7 @@ class installer
*/ */
public function check_requirements() public function check_requirements()
{ {
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
return $filesystem->is_writable([ return $filesystem->is_writable([
$this->root_path . $this->composer_filename, $this->root_path . $this->composer_filename,

View file

@ -21,6 +21,10 @@ use phpbb\db\extractor\exception\extractor_not_initialized_exception;
*/ */
abstract class base_extractor implements extractor_interface abstract class base_extractor implements extractor_interface
{ {
/**
* @var \phpbb\filesystem\filesystem
*/
protected $filesystem;
/** /**
* @var \phpbb\request\request_interface * @var \phpbb\request\request_interface
@ -83,8 +87,9 @@ abstract class base_extractor implements extractor_interface
* @param \phpbb\request\request_interface $request * @param \phpbb\request\request_interface $request
* @param \phpbb\db\driver\driver_interface $db * @param \phpbb\db\driver\driver_interface $db
*/ */
public function __construct(\phpbb\request\request_interface $request, \phpbb\db\driver\driver_interface $db) public function __construct(\phpbb\filesystem\filesystem $filesystem, \phpbb\request\request_interface $request, \phpbb\db\driver\driver_interface $db)
{ {
$this->filesystem = $filesystem;
$this->request = $request; $this->request = $request;
$this->db = $db; $this->db = $db;
$this->fp = null; $this->fp = null;
@ -158,7 +163,7 @@ abstract class base_extractor implements extractor_interface
if ($store === true) if ($store === true)
{ {
$file = sys_get_temp_dir() . '/' . $filename . $ext; $file = $this->filesystem->get_temp_dir() . '/' . $filename . $ext;
$this->fp = $open($file, 'w'); $this->fp = $open($file, 'w');

View file

@ -17,6 +17,7 @@ use bantu\IniGetWrapper\IniGetWrapper;
use phpbb\config\config; use phpbb\config\config;
use phpbb\files\factory; use phpbb\files\factory;
use phpbb\files\filespec; use phpbb\files\filespec;
use phpbb\filesystem\filesystem;
use phpbb\language\language; use phpbb\language\language;
use phpbb\request\request_interface; use phpbb\request\request_interface;
@ -28,6 +29,15 @@ class remote extends base
/** @var factory Files factory */ /** @var factory Files factory */
protected $factory; protected $factory;
/** @var filesystem Filesystem */
protected $filesystem;
/** @var language */
protected $language;
/** @var IniGetWrapper */
protected $php_ini;
/** @var request_interface */ /** @var request_interface */
protected $request; protected $request;
@ -39,15 +49,17 @@ class remote extends base
* *
* @param config $config phpBB config * @param config $config phpBB config
* @param factory $factory Files factory * @param factory $factory Files factory
* @param filesystem $filesystem Filesystem
* @param language $language Language class * @param language $language Language class
* @param IniGetWrapper $php_ini ini_get() wrapper * @param IniGetWrapper $php_ini ini_get() wrapper
* @param request_interface $request Request object * @param request_interface $request Request object
* @param string $phpbb_root_path phpBB root path * @param string $phpbb_root_path phpBB root path
*/ */
public function __construct(config $config, factory $factory, language $language, IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path) public function __construct(config $config, factory $factory, filesystem $filesystem, language $language, IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path)
{ {
$this->config = $config; $this->config = $config;
$this->factory = $factory; $this->factory = $factory;
$this->filesystem = $filesystem;
$this->language = $language; $this->language = $language;
$this->php_ini = $php_ini; $this->php_ini = $php_ini;
$this->request = $request; $this->request = $request;
@ -139,7 +151,7 @@ class remote extends base
$data = $response->getBody(); $data = $response->getBody();
$filename = tempnam(sys_get_temp_dir(), unique_id() . '-'); $filename = tempnam($this->filesystem->get_temp_dir(), unique_id() . '-');
if (!($fp = @fopen($filename, 'wb'))) if (!($fp = @fopen($filename, 'wb')))
{ {

View file

@ -17,6 +17,7 @@ use bantu\IniGetWrapper\IniGetWrapper;
use phpbb\config\config; use phpbb\config\config;
use phpbb\files\factory; use phpbb\files\factory;
use phpbb\files\filespec; use phpbb\files\filespec;
use phpbb\filesystem\filesystem;
use phpbb\language\language; use phpbb\language\language;
use phpbb\request\request_interface; use phpbb\request\request_interface;
@ -28,6 +29,15 @@ class remote_storage extends base
/** @var factory Files factory */ /** @var factory Files factory */
protected $factory; protected $factory;
/** @var filesystem Filesystem */
protected $filesystem;
/** @var language */
protected $language;
/** @var IniGetWrapper */
protected $php_ini;
/** @var request_interface */ /** @var request_interface */
protected $request; protected $request;
@ -39,15 +49,17 @@ class remote_storage extends base
* *
* @param config $config phpBB config * @param config $config phpBB config
* @param factory $factory Files factory * @param factory $factory Files factory
* @param filesystem $filesystem Filesystem
* @param language $language Language class * @param language $language Language class
* @param IniGetWrapper $php_ini ini_get() wrapper * @param IniGetWrapper $php_ini ini_get() wrapper
* @param request_interface $request Request object * @param request_interface $request Request object
* @param string $phpbb_root_path phpBB root path * @param string $phpbb_root_path phpBB root path
*/ */
public function __construct(config $config, factory $factory, language $language, IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path) public function __construct(config $config, factory $factory, filesystem $filesystem, language $language, IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path)
{ {
$this->config = $config; $this->config = $config;
$this->factory = $factory; $this->factory = $factory;
$this->filesystem = $filesystem;
$this->language = $language; $this->language = $language;
$this->php_ini = $php_ini; $this->php_ini = $php_ini;
$this->request = $request; $this->request = $request;
@ -138,7 +150,7 @@ class remote_storage extends base
$data = $response->getBody(); $data = $response->getBody();
$filename = tempnam(sys_get_temp_dir(), unique_id() . '-'); $filename = tempnam($this->filesystem->get_temp_dir(), unique_id() . '-');
if (!($fp = @fopen($filename, 'wb'))) if (!($fp = @fopen($filename, 'wb')))
{ {

View file

@ -42,14 +42,25 @@ class filesystem implements filesystem_interface
*/ */
protected $symfony_filesystem; protected $symfony_filesystem;
/**
* @var string
*/
protected $cache_temp_dir;
/**
* @var string
*/
protected $temp_dir;
/** /**
* Constructor * Constructor
*/ */
public function __construct() public function __construct($cache_temp_dir)
{ {
$this->chmod_info = array(); $this->chmod_info = array();
$this->symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem(); $this->symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem();
$this->working_directory = null; $this->working_directory = null;
$this->cache_temp_dir = $cache_temp_dir;
} }
/** /**
@ -742,4 +753,33 @@ class filesystem implements filesystem_interface
{ {
return helper::resolve_path($path, $prefix, $absolute, $return_array); return helper::resolve_path($path, $prefix, $absolute, $return_array);
} }
/**
* Get a temporary directory to write files
*
* @return string returns the directory
*/
public function get_temp_dir()
{
if (!isset($this->temp_dir))
{
$tmp_dir = (function_exists('sys_get_temp_dir')) ? sys_get_temp_dir() : '';
// Prevent trying to write to system temp dir in case of open_basedir
// restrictions being in effect
if (empty($tmp_dir) || !@file_exists($tmp_dir) || !@is_writable($tmp_dir))
{
$tmp_dir = $this->cache_temp_dir;
if (!is_dir($tmp_dir))
{
$this->filesystem->mkdir($tmp_dir, 0777);
}
}
$this->temp_dir = helper::realpath($tmp_dir);
}
return $this->temp_dir;
}
} }

View file

@ -85,7 +85,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx); $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx);
$this->request = $this->createMock('\phpbb\request\request'); $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$guessers = array( $guessers = array(

View file

@ -35,7 +35,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
->method('get') ->method('get')
->will($this->returnArgument(0)); ->will($this->returnArgument(0));
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path); $adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path);
$adapter->configure(['path' => 'images/avatars/upload']); $adapter->configure(['path' => 'images/avatars/upload']);
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory'); $adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');

View file

@ -68,7 +68,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
$this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path)); $this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path));
$this->application->add(new recreate($this->user)); $this->application->add(new recreate($this->user));
$phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_filesystem = new \phpbb\filesystem\filesystem('');
copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_1'); copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_1');
copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_2'); copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_2');

View file

@ -88,7 +88,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->symfony_request = new \phpbb\symfony_request( $this->symfony_request = new \phpbb\symfony_request(
$this->request $this->request
); );
$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->request, $this->request,

View file

@ -22,7 +22,7 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
{ {
global $phpbb_root_path, $phpEx, $phpbb_filesystem; global $phpbb_root_path, $phpEx, $phpbb_filesystem;
$phpbb_filesystem = new phpbb\filesystem\filesystem(); $phpbb_filesystem = new phpbb\filesystem\filesystem('');
$config = $this->get_database_config(); $config = $this->get_database_config();

View file

@ -36,7 +36,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$symfony_request = new \phpbb\symfony_request( $symfony_request = new \phpbb\symfony_request(
$request $request
); );
$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,
$request, $request,

View file

@ -19,7 +19,7 @@ class phpbb_error_collector_test extends phpbb_test_case
global $phpbb_filesystem; global $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_filesystem = new \phpbb\filesystem\filesystem('');
} }
public function test_collection() public function test_collection()

View file

@ -53,7 +53,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$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(''); $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()

View file

@ -29,7 +29,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
$this->filesystem = new \phpbb\filesystem(); $this->filesystem = new \phpbb\filesystem('');
$config = new \phpbb\config\config(array()); $config = new \phpbb\config\config(array());
$path_helper = new \phpbb\path_helper( $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(

View file

@ -41,7 +41,7 @@ class phpbb_files_types_base_test extends phpbb_test_case
$this->request = $this->createMock('\phpbb\request\request'); $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;

View file

@ -47,7 +47,7 @@ class phpbb_files_types_form_test extends phpbb_test_case
->method('file') ->method('file')
->willReturn(array()); ->willReturn(array());
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;

View file

@ -47,7 +47,7 @@ class phpbb_files_types_local_test extends phpbb_test_case
->method('file') ->method('file')
->willReturn(array()); ->willReturn(array());
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;

View file

@ -15,8 +15,10 @@ require_once dirname(__FILE__) . '/type_foo.php';
class phpbb_files_types_remote_test extends phpbb_test_case class phpbb_files_types_remote_test extends phpbb_test_case
{ {
/** @var string */
private $path; private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem; private $filesystem;
/** @var \phpbb\config\config */ /** @var \phpbb\config\config */
@ -49,7 +51,8 @@ class phpbb_files_types_remote_test extends phpbb_test_case
$this->config->set('remote_upload_verify', 0); $this->config->set('remote_upload_verify', 0);
$this->request = $this->createMock('\phpbb\request\request'); $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem(); $cache_path = $phpbb_root_path . 'cache/files';
$this->filesystem = new \phpbb\filesystem\filesystem($cache_path);
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
@ -71,7 +74,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
public function test_upload_fsock_fail() public function test_upload_fsock_fail()
{ {
$type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->filesystem, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png')); $upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload); $type_remote->set_upload($upload);
@ -106,7 +109,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
$php_ini->expects($this->any()) $php_ini->expects($this->any())
->method('getString') ->method('getString')
->willReturn($max_file_size); ->willReturn($max_file_size);
$type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path); $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->filesystem, $this->language, $php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png')); $upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload); $type_remote->set_upload($upload);
@ -118,7 +121,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
public function test_upload_wrong_path() public function test_upload_wrong_path()
{ {
$type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->filesystem, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png')); $upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload); $type_remote->set_upload($upload);

View file

@ -50,7 +50,7 @@ class phpbb_files_upload_test extends phpbb_test_case
$this->request = $this->createMock('\phpbb\request\request'); $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;

View file

@ -18,7 +18,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
} }
public function clean_path_data() public function clean_path_data()

View file

@ -20,7 +20,7 @@ class phpbb_filesystem_is_absolute_test extends phpbb_test_case
{ {
parent::setUp(); parent::setUp();
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
} }
static public function is_absolute_data() static public function is_absolute_data()

View file

@ -31,7 +31,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
{ {
parent::setUp(); parent::setUp();
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
} }
public function realpath_resolve_absolute_without_symlinks_data() public function realpath_resolve_absolute_without_symlinks_data()
@ -55,7 +55,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
return array(); return array();
} }
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$relative_path = $filesystem->make_path_relative(__DIR__, getcwd()); $relative_path = $filesystem->make_path_relative(__DIR__, getcwd());
return array( return array(

View file

@ -52,7 +52,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
$config['rand_seed_last_update'] = time() + 600; $config['rand_seed_last_update'] = time() + 600;
$config['remote_upload_verify'] = 0; $config['remote_upload_verify'] = 0;
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->request = $this->createMock('\phpbb\request\request'); $this->request = $this->createMock('\phpbb\request\request');
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
@ -61,7 +61,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
$container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path)); $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path));
$this->factory = new \phpbb\files\factory($container); $this->factory = new \phpbb\files\factory($container);
$container->set('files.factory', $this->factory); $container->set('files.factory', $this->factory);
$container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); $container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->filesystem, $this->language, $this->php_ini, $this->request, $phpbb_root_path));
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
} }

View file

@ -20,7 +20,7 @@ class phpbb_installer_database_helper_test extends phpbb_test_case
public function setUp() public function setUp()
{ {
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$phpbb_root_path = ''; $phpbb_root_path = '';
$this->database_helper = new \phpbb\install\helper\database($filesystem, $phpbb_root_path); $this->database_helper = new \phpbb\install\helper\database($filesystem, $phpbb_root_path);
} }

View file

@ -43,7 +43,7 @@ class module_base_test extends phpbb_test_case
$this->module = new test_installer_module($module_collection, true, false); $this->module = new test_installer_module($module_collection, true, false);
$iohandler = $this->createMock('\phpbb\install\helper\iohandler\iohandler_interface'); $iohandler = $this->createMock('\phpbb\install\helper\iohandler\iohandler_interface');
$config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \bantu\IniGetWrapper\IniGetWrapper(), '', 'php'); $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(''), new \bantu\IniGetWrapper\IniGetWrapper(), '', 'php');
$this->module->setup($config, $iohandler); $this->module->setup($config, $iohandler);
} }

View file

@ -21,7 +21,7 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = 'php'; $this->php_ext = 'php';
$this->extensions = $extensions; $this->extensions = $extensions;
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->container = $container; $this->container = $container;
$this->config = new \phpbb\config\config(array()); $this->config = new \phpbb\config\config(array());
$this->user = new \phpbb\user($lang,'\phpbb\datetime'); $this->user = new \phpbb\user($lang,'\phpbb\datetime');

View file

@ -46,7 +46,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case
$request = new phpbb_mock_request(array(), array(), array(), $this->server); $request = new phpbb_mock_request(array(), array(), array(), $this->server);
$symfony_request = new \phpbb\symfony_request($request); $symfony_request = new \phpbb\symfony_request($request);
$phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_filesystem = new \phpbb\filesystem\filesystem('');
// Set no user and trick a bit to circumvent errors // Set no user and trick a bit to circumvent errors
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);

View file

@ -44,7 +44,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
$this->session = $this->session_factory->get_session($this->db); $this->session = $this->session_factory->get_session($this->db);
global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem; global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_filesystem = new \phpbb\filesystem\filesystem('');
$this->backup_cache = $cache; $this->backup_cache = $cache;
// Change the global cache object for this test because // Change the global cache object for this test because

View file

@ -160,7 +160,7 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
{ {
global $symfony_request, $request, $phpbb_filesystem; global $symfony_request, $request, $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_filesystem = new \phpbb\filesystem\filesystem('');
$server['HTTP_HOST'] = 'localhost'; $server['HTTP_HOST'] = 'localhost';
$server['SERVER_NAME'] = 'localhost'; $server['SERVER_NAME'] = 'localhost';

View file

@ -21,7 +21,7 @@
{ {
parent::setUp(); parent::setUp();
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$phpbb_root_path = getcwd() . DIRECTORY_SEPARATOR; $phpbb_root_path = getcwd() . DIRECTORY_SEPARATOR;
$this->adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path); $this->adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path);

View file

@ -41,7 +41,7 @@ class phpbb_template_asset_test extends phpbb_test_case
$path_helper->method('get_phpbb_root_path') $path_helper->method('get_phpbb_root_path')
->willReturn($phpbb_root_path); ->willReturn($phpbb_root_path);
$asset = new asset('', $path_helper, new phpbb\filesystem\filesystem()); $asset = new asset('', $path_helper, new phpbb\filesystem\filesystem(''));
$asset->set_path($path, true); $asset->set_path($path, true);
$this->assertEquals($expected, $asset->get_path()); $this->assertEquals($expected, $asset->get_path());

View file

@ -33,7 +33,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$user = new \phpbb\user($lang, '\phpbb\datetime'); $user = new \phpbb\user($lang, '\phpbb\datetime');
$this->user = $user; $this->user = $user;
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$path_helper = new \phpbb\path_helper( $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(

View file

@ -139,7 +139,7 @@ Zeta test event in all',
dirname(__FILE__) . "/datasets/$dataset/" dirname(__FILE__) . "/datasets/$dataset/"
); );
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$path_helper = new \phpbb\path_helper( $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()

View file

@ -28,7 +28,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$defaults = $this->config_defaults(); $defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config)); $config = new \phpbb\config\config(array_merge($defaults, $new_config));
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$this->phpbb_path_helper = new \phpbb\path_helper( $this->phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(

View file

@ -80,7 +80,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$user = new \phpbb\user($lang, '\phpbb\datetime'); $user = new \phpbb\user($lang, '\phpbb\datetime');
$this->user = $user; $this->user = $user;
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$path_helper = new \phpbb\path_helper( $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(
@ -126,7 +126,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
global $phpbb_filesystem; global $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_filesystem = new \phpbb\filesystem\filesystem('');
} }
protected function tearDown() protected function tearDown()

View file

@ -22,7 +22,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$defaults = $this->config_defaults(); $defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config)); $config = new \phpbb\config\config(array_merge($defaults, $new_config));
$filesystem = new \phpbb\filesystem\filesystem(); $filesystem = new \phpbb\filesystem\filesystem('');
$this->phpbb_path_helper = new \phpbb\path_helper( $this->phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(

View file

@ -354,7 +354,7 @@ class phpbb_database_test_connection_manager
$queries = file_get_contents($filename); $queries = file_get_contents($filename);
$db_helper = new \phpbb\install\helper\database(new \phpbb\filesystem\filesystem(), $phpbb_root_path); $db_helper = new \phpbb\install\helper\database(new \phpbb\filesystem\filesystem(''), $phpbb_root_path);
$sql = $db_helper->remove_comments($queries); $sql = $db_helper->remove_comments($queries);
$sql = $db_helper->split_sql_file($sql, $this->dbms['DELIM']); $sql = $db_helper->split_sql_file($sql, $this->dbms['DELIM']);

View file

@ -75,7 +75,7 @@ class phpbb_filespec_test extends phpbb_test_case
$this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers);
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
} }

View file

@ -53,7 +53,7 @@ class phpbb_fileupload_test extends phpbb_test_case
$this->request = $this->createMock('\phpbb\request\request'); $this->request = $this->createMock('\phpbb\request\request');
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem('');
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$guessers = array( $guessers = array(
new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(),

View file

@ -17,7 +17,7 @@ class phpbb_viewonline_helper_test extends phpbb_test_case
{ {
parent::setUp(); parent::setUp();
$this->viewonline_helper = new \phpbb\viewonline_helper(new \phpbb\filesystem\filesystem()); $this->viewonline_helper = new \phpbb\viewonline_helper(new \phpbb\filesystem\filesystem(''));
} }
public function session_pages_data() public function session_pages_data()