Compare commits

..
Author SHA1 Message Date
LarsandClaude Opus 5.5 12e4079126 Docs: photo storage fix (admin uploads were private) in BETRIEB §8 and STATUS
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 20:17:18 +02:00
LarsandClaude Opus 5.5 1871c04507 Fix: photos uploaded in the admin were stored privately and did not show on the website
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
The admin upload field used Filament's default disk (FILESYSTEM_DISK=local, private), while imports
and the website use the public disk – a photo uploaded in the admin appeared in the photo list but
its web sizes returned 403 (e.g. as floor plan picture). The photo collection and the upload field
now always use the public disk; a data migration moves photos already stored privately (original and
web sizes, folder = media id) to the public disk. Tests for the upload and the migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:12:32 +02:00
6 changed files with 91 additions and 0 deletions

No files matched your search

@@ -21,6 +21,7 @@ public static function configure(Schema $schema): Schema
SpatieMediaLibraryFileUpload::make('image')
->label('Bild')
->collection(Photo::COLLECTION)
->disk('public')
->image()
->imageEditor()
->maxSize(25 * 1024)
+2
View File
@@ -45,7 +45,9 @@ protected function casts(): array
public function registerMediaCollections(): void
{
// Website photos are public files; the app's default disk (FILESYSTEM_DISK=local) is private.
$this->addMediaCollection(self::COLLECTION)
->useDisk('public')
->singleFile()
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
}
@@ -0,0 +1,48 @@
<?php
use App\Models\Photo;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
return new class extends Migration
{
/**
* Photos uploaded in the admin landed on the private default disk ("local"), so the website could not
* show them. Moves their files (original and web sizes, folder = media id) to the public disk.
* Safe to run again: only media not yet on the public disk are touched.
*/
public function up(): void
{
$media = DB::table('media')
->where('model_type', Photo::class)
->where(fn ($query) => $query->where('disk', '!=', 'public')->orWhere('conversions_disk', '!=', 'public'))
->get(['id', 'disk', 'conversions_disk']);
foreach ($media as $item) {
$folder = (string) $item->id;
$public = Storage::disk('public');
$disks = array_values(array_diff(array_unique([$item->disk, $item->conversions_disk ?: $item->disk]), ['public']));
if (array_filter($disks, fn (string $diskName): bool => config("filesystems.disks.{$diskName}") === null) !== []) {
continue;
}
foreach ($disks as $diskName) {
$source = Storage::disk($diskName);
foreach ($source->allFiles($folder) as $file) {
$public->writeStream($file, $source->readStream($file));
}
$source->deleteDirectory($folder);
}
DB::table('media')->where('id', $item->id)->update(['disk' => 'public', 'conversions_disk' => 'public']);
}
}
public function down(): void
{
// Files stay public; moving them back to a private disk would hide them from the website again.
}
};
+1
View File
@@ -150,6 +150,7 @@ ## 8. Bekannte Eigenheiten und Lösungen
| Nach dem Umschalten lief die alte Version weiter | Strato-OPcache speichert Skripte unter dem Symlink-Pfad `current/…` | `.htaccess` zeigt auf den konkreten Ordner `releases/<version>/public` und wird bei jedem Umschalten neu geschrieben |
| Links mit `/current/public` (z. B. Sitemap) | Laravel leitet den Basis-Pfad aus dem Skript-Pfad ab | `URL::forceRootUrl(APP_URL)` außerhalb von local/testing (`AppServiceProvider`) |
| HTTP 500 „Composer platform“ | Web-PHP des Pakets ist 8.3 | `AddType application/x-httpd-php84 .php` in der Ordner-`.htaccess` |
| Im Admin hochgeladenes Foto erscheint in der Fotoliste, auf der Website/im Grundriss-Editor aber als leeres Bild (HTTP 403) | Upload-Feld nahm Filaments Standard-Speicher `FILESYSTEM_DISK=local` (privat, `storage/app/private/<media-id>`); Import und Website nutzen `public` | Seit 23.10.2026 (`1871c04`): Fotos immer auf `public` (`Photo`-Sammlung `useDisk('public')`, Upload-Feld `->disk('public')`); Migration `2026_10_23_171001_move_photo_media_to_the_public_disk` hat vorhandene private Fotos verschoben (stommer.info: Foto 41). Direkt nach dem Verschieben kann Strato die Adresse kurz noch mit 403 beantworten |
| SSH „connection closed“ | falscher Server `ssh.strato.de` | paketspezifischer Server (§2) |
| Domain-Ziel `current/public` nicht wählbar | Strato erlaubt kein Symlink-Ziel | Domain auf den Deploy-Ordner, `.htaccess` leitet weiter |
| Ersteinrichtung mit Factories schlägt fehl | Produktion ohne Dev-Pakete | `ProductionSeeder` |
+2
View File
@@ -109,6 +109,8 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
**Fertig:** alle 15 Bausteine, Kopf/Fuß/Banner/mobile Buchungsleiste, Logo aus `styles/satz4` (SVG-Master + WebP), Favicon (Eckbau mit Rundbogengaube), Bäderstil-Details des Hauses (Rundbogen mit Fasche und Schlussstein, Rundbogengaube, Kopfbänder als Eckkonsolen, Balkongeländer), Farben aus dem Logo, Schriften selbst gehostet. Gearbeitet wird im eigenen Worktree auf `theme/seebad`, ausgeliefert nur über `main`.
**Behoben 23.10.2026:** Im Admin hochgeladene Fotos landeten im privaten Speicher und waren auf der Website unsichtbar (403) – jetzt immer öffentlich, vorhandene per Migration verschoben (BETRIEB.md §8).
**Offen (Design):**
- Ziffer 0 mit Schrägstrich (Schrift Atkinson Hyperlegible) in Preisen und Daten – Entscheidung Lars: lassen oder Preise/Daten in anderer Schrift.
- Seite „Kühlungsborn“ wirkt leer, bis es den Baustein „Tipps der Gastgeberin“ gibt (Vignetten liegen bereit: `motifs/vignette-*.svg`).
+37
View File
@@ -8,6 +8,7 @@
use App\Filament\Resources\Amenities\AmenityResource;
use App\Filament\Resources\Faqs\FaqResource;
use App\Filament\Resources\Notices\NoticeResource;
use App\Filament\Resources\Photos\Pages\CreatePhoto;
use App\Filament\Resources\Photos\Pages\ListPhotos;
use App\Filament\Resources\Photos\PhotoResource;
use App\Filament\Resources\Properties\PropertyResource;
@@ -87,6 +88,42 @@ public function test_several_photos_are_uploaded_at_once(): void
$this->assertSame(['Wohn zimmer', 'Kueche'], Photo::orderBy('sort_order')->pluck('alt_text')->all());
}
public function test_photo_uploaded_in_the_admin_is_stored_on_the_public_disk(): void
{
Storage::fake('local');
Livewire::test(CreatePhoto::class)
->fillForm([
'image' => [UploadedFile::fake()->image('grundriss.png', 1600, 900)],
'alt_text' => 'Grundriss mit Teppichen',
'category' => PhotoCategory::Apartment,
])
->call('create')
->assertHasNoFormErrors();
$media = Photo::query()->where('alt_text', 'Grundriss mit Teppichen')->sole()->getFirstMedia(Photo::COLLECTION);
$this->assertSame(['public', 'public'], [$media->disk, $media->conversions_disk]);
Storage::disk('public')->assertExists($media->id.'/'.$media->file_name);
$this->assertSame([], Storage::disk('local')->allFiles());
}
public function test_migration_moves_photos_from_the_private_disk_to_the_public_disk(): void
{
Storage::fake('local');
$photo = Photo::factory()->create();
$media = $photo->addMedia(UploadedFile::fake()->image('alt.jpg', 1200, 800))->toMediaCollection(Photo::COLLECTION, 'local');
Storage::disk('local')->assertExists($media->id.'/alt.jpg');
(require database_path('migrations/2026_10_23_171001_move_photo_media_to_the_public_disk.php'))->up();
$media->refresh();
$this->assertSame(['public', 'public'], [$media->disk, $media->conversions_disk]);
Storage::disk('public')->assertExists($media->id.'/alt.jpg');
Storage::disk('public')->assertExists($media->id.'/conversions/alt-lg.webp');
Storage::disk('local')->assertMissing($media->id.'/alt.jpg');
$this->assertStringEndsWith('/conversions/alt-lg.webp', $photo->fresh()->url('lg'));
}
public function test_notices_are_visible_only_within_their_dates(): void
{
$this->travelTo(CarbonImmutable::parse('2026-11-10'));