1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 06:51:33 +02:00

[ticket/17357] Remove file_info from storage

PHPBB-17357
This commit is contained in:
Ruben Calvo
2024-06-30 13:59:41 +02:00
parent 1dacbf6bde
commit 877e364cbd
16 changed files with 118 additions and 281 deletions

View File

@@ -18,8 +18,6 @@ use phpbb\storage\exception\storage_exception;
use phpbb\filesystem\exception\filesystem_exception;
use phpbb\filesystem\filesystem;
use phpbb\filesystem\helper as filesystem_helper;
use phpbb\mimetype\guesser;
use FastImageSize\FastImageSize;
/**
* Experimental
@@ -33,20 +31,6 @@ class local implements adapter_interface, stream_interface
*/
protected $filesystem;
/**
* FastImageSize
*
* @var FastImageSize
*/
protected $imagesize;
/**
* Mimetype Guesser component
*
* @var guesser
*/
protected $mimetype_guesser;
/**
* @var string path
*/
@@ -77,15 +61,11 @@ class local implements adapter_interface, stream_interface
* Constructor
*
* @param filesystem $filesystem
* @param FastImageSize $imagesize
* @param guesser $mimetype_guesser
* @param string $phpbb_root_path
*/
public function __construct(filesystem $filesystem, FastImageSize $imagesize, guesser $mimetype_guesser, string $phpbb_root_path)
public function __construct(filesystem $filesystem, string $phpbb_root_path)
{
$this->filesystem = $filesystem;
$this->imagesize = $imagesize;
$this->mimetype_guesser = $mimetype_guesser;
$this->phpbb_root_path = $phpbb_root_path;
}
@@ -294,15 +274,9 @@ class local implements adapter_interface, stream_interface
}
/**
* Get file size
*
* @param string $path The file
*
* @return array Properties
*
* @throws storage_exception When cannot get size
* {@inheritdoc}
*/
public function file_size(string $path): array
public function file_size(string $path): int
{
$size = @filesize($this->root_path . $this->get_path($path) . $this->get_filename($path));
@@ -311,72 +285,7 @@ class local implements adapter_interface, stream_interface
throw new storage_exception('STORAGE_CANNOT_GET_FILESIZE');
}
return ['size' => $size];
}
/**
* Get file mimetype
*
* @param string $path The file
*
* @return array Properties
*/
public function file_mimetype(string $path): array
{
return ['mimetype' => $this->mimetype_guesser->guess($this->root_path . $this->get_path($path) . $this->get_filename($path))];
}
/**
* Get image dimensions
*
* @param string $path The file
*
* @return array Properties
*/
protected function image_dimensions(string $path): array
{
$size = $this->imagesize->getImageSize($this->root_path . $this->get_path($path) . $this->get_filename($path));
// For not supported types like swf
if ($size === false)
{
$imsize = getimagesize($this->root_path . $this->get_path($path) . $this->get_filename($path));
$size = ['width' => $imsize[0], 'height' => $imsize[1]];
}
return ['image_width' => $size['width'], 'image_height' => $size['height']];
}
/**
* Get image width
*
* @param string $path The file
*
* @return array Properties
*/
public function file_image_width(string $path): array
{
return $this->image_dimensions($path);
}
/**
* Get image height
*
* @param string $path The file
*
* @return array Properties
*/
public function file_image_height(string $path): array
{
return $this->image_dimensions($path);
}
/**
* {@inheritdoc}
*/
public function get_link(string $path): string
{
return generate_board_url() . '/' . $this->path . $path;
return $size;
}
/**