mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-12 03:42:05 +02:00
[ticket/15747] Change parameter depth to boolean
PHPBB3-15747
This commit is contained in:
parent
1c406c70e0
commit
c24b801746
@ -289,13 +289,13 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_enab
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_purge_on_remove', '1');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\provider', 'phpbb\storage\provider\local');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\config\path', 'files');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\config\depth', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\config\subfolders', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\avatar\provider', 'phpbb\storage\provider\local');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\avatar\config\path', 'images/avatars/upload');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\avatar\config\depth', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\avatar\config\subfolders', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\backup\provider', 'phpbb\storage\provider\local');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\backup\config\path', 'store');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\backup\config\depth', '0');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\backup\config\subfolders', '0');
|
||||
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cache_last_gc', '0', 1);
|
||||
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('cron_lock', '0', 1);
|
||||
|
@ -55,9 +55,10 @@ $lang = array_merge($lang, array(
|
||||
'STORAGE_BACKUP_TITLE' => 'Backup storage',
|
||||
|
||||
// Local adapter
|
||||
'STORAGE_ADAPTER_LOCAL_NAME' => 'Local',
|
||||
'STORAGE_ADAPTER_LOCAL_OPTION_PATH' => 'Path',
|
||||
'STORAGE_ADAPTER_LOCAL_OPTION_DEPTH' => 'Depth',
|
||||
'STORAGE_ADAPTER_LOCAL_NAME' => 'Local',
|
||||
'STORAGE_ADAPTER_LOCAL_OPTION_PATH' => 'Path',
|
||||
'STORAGE_ADAPTER_LOCAL_OPTION_SUBFOLDERS' => 'Organize in subfolders',
|
||||
'STORAGE_ADAPTER_LOCAL_OPTION_SUBFOLDERS_EXPLAIN' => 'Some web servers may have problems storing large number of files in a single directory. Enable this option to distribute files in different directories.',
|
||||
|
||||
// Form validation
|
||||
'STORAGE_UPDATE_SUCCESSFUL' => 'All storage types were successfully updated.',
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
|
||||
class storage_adapter_local_depth_rename extends \phpbb\db\migration\migration
|
||||
{
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v330\storage_adapter_local_depth',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('if', array(
|
||||
($this->config['storage\\attachment\\provider'] == \phpbb\storage\provider\local::class),
|
||||
array('config.delete', array('storage\\attachment\\config\\depth')),
|
||||
array('config.add', array('storage\\attachment\\config\\subfolders', '0')),
|
||||
)),
|
||||
array('if', array(
|
||||
($this->config['storage\\avatar\\provider'] == \phpbb\storage\provider\local::class),
|
||||
array('config.delete', array('storage\\avatar\\config\\depth')),
|
||||
array('config.add', array('storage\\avatar\\config\\subfolders', '0')),
|
||||
)),
|
||||
array('if', array(
|
||||
($this->config['storage\\backup\\provider'] == \phpbb\storage\provider\local::class),
|
||||
array('config.delete', array('storage\\backup\\config\\depth')),
|
||||
array('config.add', array('storage\\backup\\config\\subfolders', '0')),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
@ -73,10 +73,17 @@ class local implements adapter_interface, stream_interface
|
||||
* This is for those who have problems storing a large number of files in
|
||||
* a single directory.
|
||||
* More info: https://tracker.phpbb.com/browse/PHPBB3-15371
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* @var bool subfolders
|
||||
*/
|
||||
protected $subfolders;
|
||||
|
||||
/*
|
||||
* @var int dir_depth
|
||||
*/
|
||||
protected $dir_depth;
|
||||
protected $dir_depth = 2;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -101,7 +108,7 @@ class local implements adapter_interface, stream_interface
|
||||
|
||||
$this->path = $options['path'];
|
||||
$this->root_path = $this->phpbb_root_path . $options['path'];
|
||||
$this->dir_depth = (int) $options['depth'];
|
||||
$this->subfolders = (bool) $options['subfolders'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,19 +277,21 @@ class local implements adapter_interface, stream_interface
|
||||
*/
|
||||
protected function get_path($path)
|
||||
{
|
||||
$dirname = dirname($path);
|
||||
|
||||
$hash = md5(basename($path));
|
||||
|
||||
$parts = str_split($hash, 2);
|
||||
$parts = array_slice($parts, 0, $this->dir_depth);
|
||||
|
||||
// Create path
|
||||
$path = $dirname . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!empty($parts))
|
||||
if ($this->subfolders)
|
||||
{
|
||||
$path .= implode(DIRECTORY_SEPARATOR, $parts) . DIRECTORY_SEPARATOR;
|
||||
$hash = md5(basename($path));
|
||||
|
||||
$parts = str_split($hash, 2);
|
||||
$parts = array_slice($parts, 0, $this->dir_depth);
|
||||
|
||||
// Create path
|
||||
$dirname = dirname($path);
|
||||
$path = $dirname . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!empty($parts))
|
||||
{
|
||||
$path .= implode(DIRECTORY_SEPARATOR, $parts) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
@ -37,8 +37,14 @@ class local implements provider_interface
|
||||
public function get_options()
|
||||
{
|
||||
return [
|
||||
'path' => array('type' => 'text'),
|
||||
'depth' => array('type' => 'text'),
|
||||
'path' => ['type' => 'text'],
|
||||
'subfolders' => [
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'ENABLE' => '1',
|
||||
'DISABLE' => '0',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
$phpbb_root_path = getcwd() . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->adapter = new \phpbb\storage\adapter\local($this->filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path);
|
||||
$this->adapter->configure(['path' => 'test_path', 'depth' => 2]);
|
||||
$this->adapter->configure(['path' => 'test_path', 'subfolders' => true]);
|
||||
|
||||
$this->path = $phpbb_root_path . 'test_path/';
|
||||
mkdir($this->path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user