diff --git a/social.yaml b/social.yaml index 643570294c..69f8723ac4 100644 --- a/social.yaml +++ b/social.yaml @@ -45,14 +45,12 @@ parameters: avatar: server: ssl: - dir: "%kernel.project_dir%/file/avatar/" default: "/assets/default-avatar.svg" max_size_px: 300 cover: server: ssl: - dir: "%kernel.project_dir%/file/cover/" max_size_px: 300 javascript: @@ -123,7 +121,6 @@ parameters: width: 128 height: 128 smart_crop: false - dir: "%kernel.project_dir%/file/embed/" theme: diff --git a/src/Entity/Attachment.php b/src/Entity/Attachment.php index b1bdb0e476..1c00445d30 100644 --- a/src/Entity/Attachment.php +++ b/src/Entity/Attachment.php @@ -323,7 +323,7 @@ class Attachment extends Entity public function getPath() { $filename = $this->getFilename(); - return is_null($filename) ? null : Common::config('attachments', 'dir') . $filename; + return is_null($filename) ? null : Common::config('attachments', 'dir') . DIRECTORY_SEPARATOR . $filename; } public function getUrl() diff --git a/src/Entity/AttachmentThumbnail.php b/src/Entity/AttachmentThumbnail.php index 17ff541862..324f8f09f8 100644 --- a/src/Entity/AttachmentThumbnail.php +++ b/src/Entity/AttachmentThumbnail.php @@ -211,7 +211,7 @@ class AttachmentThumbnail extends Entity public function getPath() { - return Common::config('thumbnail', 'dir') . $this->getFilename(); + return Common::config('thumbnail', 'dir') . DIRECTORY_SEPARATOR . $this->getFilename(); } public function getUrl() diff --git a/src/Util/Exception/NoSuchFileException.php b/src/Util/Exception/NoSuchFileException.php index 61c6bb2a42..743f1ea19c 100644 --- a/src/Util/Exception/NoSuchFileException.php +++ b/src/Util/Exception/NoSuchFileException.php @@ -19,12 +19,10 @@ namespace App\Util\Exception; -use function App\Core\I18n\_m; - class NoSuchFileException extends NotFoundException { - public function __construct() + public function __construct(string $m = 'No such file found.') { - parent::__construct(_m('No such file found')); + parent::__construct($m); } } diff --git a/src/Util/Exception/NotStoredLocallyException.php b/src/Util/Exception/NotStoredLocallyException.php index a39ff767d3..ab3257018c 100644 --- a/src/Util/Exception/NotStoredLocallyException.php +++ b/src/Util/Exception/NotStoredLocallyException.php @@ -25,6 +25,6 @@ class NotStoredLocallyException extends NoSuchFileException { public function __construct() { - parent::__construct(_m('This attachment is not stored locally')); + parent::__construct(_m('This attachment is not stored locally.')); } } diff --git a/tests/Controller/AdminTest.php b/tests/Controller/AdminTest.php index 75557f40c9..3a826233ac 100644 --- a/tests/Controller/AdminTest.php +++ b/tests/Controller/AdminTest.php @@ -54,7 +54,7 @@ class AdminTest extends GNUsocialTestCase public function testSiteString() { - $this->test(['attachments', 'dir'], fn () => INSTALLDIR . '/foo'); + $this->test(['attachments', 'dir'], fn () => Common::config('storage', 'dir') . 'foo' . DIRECTORY_SEPARATOR); } public function testSiteInt() diff --git a/tests/Entity/AttachmentThumbnailTest.php b/tests/Entity/AttachmentThumbnailTest.php index 8d257ddb28..ab2c624f69 100644 --- a/tests/Entity/AttachmentThumbnailTest.php +++ b/tests/Entity/AttachmentThumbnailTest.php @@ -35,7 +35,7 @@ class AttachmentThumbnailTest extends GNUsocialTestCase { parent::bootKernel(); - // Data fixture already loaded this file, but we need to get it's hash to find it + // Data fixture already loaded this file, but we need to get its hash to find it $file = new \SplFileInfo(INSTALLDIR . '/tests/sample-uploads/attachment-lifecycle-target.jpg'); Event::handle('HashFile', [$file->getPathname(), &$hash]); $attachment = DB::findOneBy('attachment', ['filehash' => $hash]); @@ -61,7 +61,7 @@ class AttachmentThumbnailTest extends GNUsocialTestCase $attachment->deleteStorage(); - // This was deleted earlier, an the backed storage as well, so we can't generate another thumbnail + // This was deleted earlier, and the backed storage as well, so we can't generate another thumbnail static::assertThrows(NotStoredLocallyException::class, fn () => AttachmentThumbnail::getOrCreate($attachment, width: 4, height: 4, crop: false)); $attachment->kill();