mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 10:16:36 +02:00
[ticket/15286] Update use storage in avatars
PHPBB3-15286
This commit is contained in:
@@ -16,7 +16,7 @@ namespace phpbb\attachment;
|
||||
use \phpbb\config\config;
|
||||
use \phpbb\db\driver\driver_interface;
|
||||
use \phpbb\event\dispatcher;
|
||||
use \phpbb\filesystem\filesystem;
|
||||
use \phpbb\storage\storage;
|
||||
|
||||
/**
|
||||
* Attachment delete class
|
||||
@@ -32,14 +32,11 @@ class delete
|
||||
/** @var dispatcher */
|
||||
protected $dispatcher;
|
||||
|
||||
/** @var filesystem */
|
||||
protected $filesystem;
|
||||
|
||||
/** @var resync */
|
||||
protected $resync;
|
||||
|
||||
/** @var string phpBB root path */
|
||||
protected $phpbb_root_path;
|
||||
/** @var storage */
|
||||
protected $storage;
|
||||
|
||||
/** @var array Attachement IDs */
|
||||
protected $ids;
|
||||
@@ -71,18 +68,15 @@ class delete
|
||||
* @param config $config
|
||||
* @param driver_interface $db
|
||||
* @param dispatcher $dispatcher
|
||||
* @param filesystem $filesystem
|
||||
* @param resync $resync
|
||||
* @param string $phpbb_root_path
|
||||
* @param storage $storage
|
||||
*/
|
||||
public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, filesystem $filesystem, resync $resync, $phpbb_root_path)
|
||||
public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, resync $resync, $storage)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->resync = $resync;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->storage = $storage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,8 +155,8 @@ class delete
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Delete attachments from filesystem
|
||||
$this->remove_from_filesystem();
|
||||
// Delete attachments from storage
|
||||
$this->remove_from_storage();
|
||||
|
||||
// If we do not resync, we do not need to adjust any message, post, topic or user entries
|
||||
if (!$resync)
|
||||
@@ -327,9 +321,9 @@ class delete
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete attachments from filesystem
|
||||
* Delete attachments from storage
|
||||
*/
|
||||
protected function remove_from_filesystem()
|
||||
protected function remove_from_storage()
|
||||
{
|
||||
$space_removed = $files_removed = 0;
|
||||
|
||||
@@ -388,7 +382,7 @@ class delete
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete attachment from filesystem
|
||||
* Delete attachment from storage
|
||||
*
|
||||
* @param string $filename Filename of attachment
|
||||
* @param string $mode Delete mode
|
||||
@@ -412,17 +406,16 @@ class delete
|
||||
}
|
||||
|
||||
$filename = ($mode == 'thumbnail') ? 'thumb_' . utf8_basename($filename) : utf8_basename($filename);
|
||||
$filepath = $this->phpbb_root_path . $this->config['upload_path'] . '/' . $filename;
|
||||
|
||||
try
|
||||
{
|
||||
if ($this->filesystem->exists($filepath))
|
||||
if ($this->storage->exists($filename))
|
||||
{
|
||||
$this->filesystem->remove($this->phpbb_root_path . $this->config['upload_path'] . '/' . $filename);
|
||||
$this->storage->remove($filename);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $exception)
|
||||
catch (\phpbb\storage\exception\exception $exception)
|
||||
{
|
||||
// Fail is covered by return statement below
|
||||
}
|
||||
|
Reference in New Issue
Block a user