mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 01:06:48 +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
|
||||
}
|
||||
|
@@ -81,9 +81,8 @@ class upload
|
||||
* @param dispatcher $phpbb_dispatcher
|
||||
* @param plupload $plupload
|
||||
* @param user $user
|
||||
* @param $phpbb_root_path
|
||||
*/
|
||||
public function __construct(auth $auth, service $cache, config $config, \phpbb\files\upload $files_upload, language $language, guesser $mimetype_guesser, dispatcher $phpbb_dispatcher, plupload $plupload, storage $storage, user $user, $phpbb_root_path)
|
||||
public function __construct(auth $auth, service $cache, config $config, \phpbb\files\upload $files_upload, language $language, guesser $mimetype_guesser, dispatcher $phpbb_dispatcher, plupload $plupload, storage $storage, user $user)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->cache = $cache;
|
||||
@@ -95,7 +94,6 @@ class upload
|
||||
$this->plupload = $plupload;
|
||||
$this->storage = $storage;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,26 +307,6 @@ class upload
|
||||
*/
|
||||
protected function check_disk_space()
|
||||
{
|
||||
if ($free_space = @disk_free_space($this->phpbb_root_path . $this->config['upload_path']))
|
||||
{
|
||||
if ($free_space <= $this->file->get('filesize'))
|
||||
{
|
||||
if ($this->auth->acl_get('a_'))
|
||||
{
|
||||
$this->file_data['error'][] = $this->language->lang('ATTACH_DISK_FULL');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->file_data['error'][] = $this->language->lang('ATTACH_QUOTA_REACHED');
|
||||
}
|
||||
$this->file_data['post_attach'] = false;
|
||||
|
||||
$this->file->remove();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user