mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-05 14:04:57 +02:00
[ticket/15965] Fix hardcoded directory
PHPBB3-15965
This commit is contained in:
parent
33afd3f350
commit
96491a70e8
@ -208,6 +208,7 @@ services:
|
|||||||
console.command.thumbnail.delete:
|
console.command.thumbnail.delete:
|
||||||
class: phpbb\console\command\thumbnail\delete
|
class: phpbb\console\command\thumbnail\delete
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@config'
|
||||||
- '@user'
|
- '@user'
|
||||||
- '@dbal.conn'
|
- '@dbal.conn'
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
@ -217,6 +218,7 @@ services:
|
|||||||
console.command.thumbnail.generate:
|
console.command.thumbnail.generate:
|
||||||
class: phpbb\console\command\thumbnail\generate
|
class: phpbb\console\command\thumbnail\generate
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@config'
|
||||||
- '@user'
|
- '@user'
|
||||||
- '@dbal.conn'
|
- '@dbal.conn'
|
||||||
- '@cache'
|
- '@cache'
|
||||||
|
@ -18,6 +18,11 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
|
|
||||||
class delete extends \phpbb\console\command\command
|
class delete extends \phpbb\console\command\command
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var \phpbb\config\config
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpbb\db\driver\driver_interface
|
* @var \phpbb\db\driver\driver_interface
|
||||||
*/
|
*/
|
||||||
@ -32,12 +37,14 @@ class delete extends \phpbb\console\command\command
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
* @param \config\config $config The config
|
||||||
* @param \phpbb\user $user The user object (used to get language information)
|
* @param \phpbb\user $user The user object (used to get language information)
|
||||||
* @param \phpbb\db\driver\driver_interface $db Database connection
|
* @param \phpbb\db\driver\driver_interface $db Database connection
|
||||||
* @param string $phpbb_root_path Root path
|
* @param string $phpbb_root_path Root path
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db, $phpbb_root_path)
|
public function __construct(\phpbb\config\config $config, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, $phpbb_root_path)
|
||||||
{
|
{
|
||||||
|
$this->config = $config;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
|
||||||
@ -101,7 +108,7 @@ class delete extends \phpbb\console\command\command
|
|||||||
$return = 0;
|
$return = 0;
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$thumbnail_path = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
|
$thumbnail_path = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename'];
|
||||||
|
|
||||||
if (@unlink($thumbnail_path))
|
if (@unlink($thumbnail_path))
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,11 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
|
|
||||||
class generate extends \phpbb\console\command\command
|
class generate extends \phpbb\console\command\command
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var \phpbb\config\config
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpbb\db\driver\driver_interface
|
* @var \phpbb\db\driver\driver_interface
|
||||||
*/
|
*/
|
||||||
@ -45,14 +50,16 @@ class generate extends \phpbb\console\command\command
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
* @param \config\config $config The config
|
||||||
* @param \phpbb\user $user The user object (used to get language information)
|
* @param \phpbb\user $user The user object (used to get language information)
|
||||||
* @param \phpbb\db\driver\driver_interface $db Database connection
|
* @param \phpbb\db\driver\driver_interface $db Database connection
|
||||||
* @param \phpbb\cache\service $cache The cache service
|
* @param \phpbb\cache\service $cache The cache service
|
||||||
* @param string $phpbb_root_path Root path
|
* @param string $phpbb_root_path Root path
|
||||||
* @param string $php_ext PHP extension
|
* @param string $php_ext PHP extension
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $phpbb_root_path, $php_ext)
|
public function __construct(\phpbb\config\config $config, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
|
$this->config = $config;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
@ -126,8 +133,8 @@ class generate extends \phpbb\console\command\command
|
|||||||
{
|
{
|
||||||
if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE)
|
if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE)
|
||||||
{
|
{
|
||||||
$source = $this->phpbb_root_path . 'files/' . $row['physical_filename'];
|
$source = $this->phpbb_root_path . $this->config['upload_path'] . '/' . $row['physical_filename'];
|
||||||
$destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
|
$destination = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename'];
|
||||||
|
|
||||||
if (create_thumbnail($source, $destination, $row['mimetype']))
|
if (create_thumbnail($source, $destination, $row['mimetype']))
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
|
|||||||
$config = $this->config = new \phpbb\config\config(array(
|
$config = $this->config = new \phpbb\config\config(array(
|
||||||
'img_min_thumb_filesize' => 2,
|
'img_min_thumb_filesize' => 2,
|
||||||
'img_max_thumb_width' => 2,
|
'img_max_thumb_width' => 2,
|
||||||
|
'upload_path' => 'files',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->db = $this->db = $this->new_dbal();
|
$this->db = $this->db = $this->new_dbal();
|
||||||
@ -63,8 +64,8 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
$this->application = new Application();
|
$this->application = new Application();
|
||||||
$this->application->add(new generate($this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx));
|
$this->application->add(new generate($config, $this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx));
|
||||||
$this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path));
|
$this->application->add(new delete($config, $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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user