-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Insert the avatar into the new file system during import, instead of …
…the `wcf1_user_avatar` table
- Loading branch information
1 parent
e3c7bb4
commit bfcd4d3
Showing
2 changed files
with
70 additions
and
57 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
wcfsetup/install/files/lib/system/importer/AbstractFileImporter.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace wcf\system\importer; | ||
|
||
use wcf\data\file\File; | ||
use wcf\data\file\FileEditor; | ||
|
||
/** | ||
* Import files. | ||
* | ||
* @author Olaf Braun | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
*/ | ||
abstract class AbstractFileImporter extends AbstractImporter | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
protected $className = File::class; | ||
|
||
/** | ||
* object type for `com.woltlab.wcf.file` | ||
*/ | ||
protected string $objectType; | ||
|
||
|
||
protected function importFile(string $fileLocation, ?string $filename = null): ?File | ||
{ | ||
// check file location | ||
if (!\is_readable($fileLocation)) { | ||
return null; | ||
} | ||
|
||
$filename = $filename ?: \basename($fileLocation); | ||
$file = FileEditor::createFromExistingFile($fileLocation, $filename, $this->objectType, true); | ||
|
||
if ($file === null) { | ||
return null; | ||
} | ||
|
||
if ($this->isValidFile($file)) { | ||
return $file; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
abstract protected function isValidFile(File $file): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters