mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/15747] Change parameter depth to boolean
PHPBB3-15747
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user