1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/17361] Rewrite storage

PHPBB-17361
This commit is contained in:
Ruben Calvo
2024-11-24 00:15:10 +01:00
parent 688dbb0837
commit e9c445925b
24 changed files with 407 additions and 762 deletions

View File

@@ -15,7 +15,7 @@ namespace phpbb\db\migration\data\v400;
use phpbb\db\migration\container_aware_migration;
use phpbb\storage\exception\storage_exception;
use phpbb\storage\storage;
use phpbb\storage\file_tracker;
class storage_track extends container_aware_migration
{
@@ -70,8 +70,8 @@ class storage_track extends container_aware_migration
public function track_avatars()
{
/** @var storage $storage */
$storage = $this->container->get('storage.avatar');
/** @var file_tracker $file_tracker */
$file_tracker = $this->container->get('storage.file_tracker');
$sql = 'SELECT user_avatar
FROM ' . USERS_TABLE . "
@@ -95,7 +95,8 @@ class storage_track extends container_aware_migration
try
{
$storage->track_file($this->config['avatar_salt'] . '_' . ($avatar_group ? 'g' : '') . $filename . '.' . $ext);
$filename = $this->config['avatar_salt'] . '_' . ($avatar_group ? 'g' : '') . $filename . '.' . $ext;
$file_tracker->track_file('avatar', $filename, filesize($this->phpbb_root_path . $this->config['storage\\avatar\\config\\path'] . '/' . $filename));
}
catch (storage_exception $e)
{
@@ -107,8 +108,8 @@ class storage_track extends container_aware_migration
public function track_attachments()
{
/** @var storage $storage */
$storage = $this->container->get('storage.attachment');
/** @var file_tracker $file_tracker */
$file_tracker = $this->container->get('storage.file_tracker');
$sql = 'SELECT physical_filename, thumbnail
FROM ' . ATTACHMENTS_TABLE;
@@ -119,7 +120,7 @@ class storage_track extends container_aware_migration
{
try
{
$storage->track_file($row['physical_filename']);
$file_tracker->track_file('attachment', $row['physical_filename'], filesize($this->phpbb_root_path . $this->config['storage\\attachment\\config\\path'] . '/' . $row['physical_filename']));
}
catch (storage_exception $e)
{
@@ -130,7 +131,7 @@ class storage_track extends container_aware_migration
{
try
{
$storage->track_file('thumb_' . $row['physical_filename']);
$file_tracker->track_file('attachment', 'thumb_' . $row['physical_filename'], filesize($this->phpbb_root_path . $this->config['storage\\attachment\\config\\path'] . '/thumb_' . $row['physical_filename']));
}
catch (storage_exception $e)
{
@@ -143,8 +144,8 @@ class storage_track extends container_aware_migration
public function track_backups()
{
/** @var storage $storage */
$storage = $this->container->get('storage.backup');
/** @var file_tracker $file_tracker */
$file_tracker = $this->container->get('storage.file_tracker');
$sql = 'SELECT filename
FROM ' . BACKUPS_TABLE;
@@ -155,7 +156,7 @@ class storage_track extends container_aware_migration
{
try
{
$storage->track_file($row['filename']);
$file_tracker->track_file('backup', $row['filename'], filesize($this->phpbb_root_path . $this->config['storage\\backup\\config\\path'] . '/' . $row['filename']));
}
catch (storage_exception $e)
{

View File

@@ -0,0 +1,48 @@
<?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\v400;
use phpbb\db\migration\container_aware_migration;
class storage_track_index extends container_aware_migration
{
public static function depends_on()
{
return [
'\phpbb\db\migration\data\v400\storage_track',
];
}
public function update_schema()
{
return [
'add_unique_index' => [
$this->table_prefix . 'storage' => [
'uidx_storage' => ['file_path', 'storage'],
],
]
];
}
public function revert_schema()
{
return [
'drop_keys' => [
$this->table_prefix . 'storage' => [
'uidx_storage',
],
],
];
}
}