Bug Fixes CMS #25
No files matched your search
@@ -6,6 +6,7 @@
|
|||||||
use App\Domain\Cms\Sections\SectionStyle;
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -282,7 +283,14 @@ private static function state(): array
|
|||||||
return self::$memo;
|
return self::$memo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Die Prüfregeln der Widgets lesen die Palette bei jedem Speichern, auch beim Einspielen der Migrationen (Seeder), wenn
|
||||||
|
// site_settings noch fehlt. Eine fehlgeschlagene Abfrage würde dort in PostgreSQL die ganze Transaktion abbrechen
|
||||||
|
// (SQLSTATE 25P02), auch wenn der Fehler abgefangen wird. Deshalb wird vorher geprüft und nichts gemerkt.
|
||||||
try {
|
try {
|
||||||
|
if (! Schema::hasTable('site_settings')) {
|
||||||
|
return self::read([]);
|
||||||
|
}
|
||||||
|
|
||||||
$stored = Cache::rememberForever(self::CACHE_KEY, static function (): array {
|
$stored = Cache::rememberForever(self::CACHE_KEY, static function (): array {
|
||||||
$row = SiteSetting::query()->find(self::KEY);
|
$row = SiteSetting::query()->find(self::KEY);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
use Filament\Actions\Testing\TestAction;
|
use Filament\Actions\Testing\TestAction;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
@@ -264,4 +266,26 @@ public function test_editor_saves_sizes_and_colour_and_shows_them_in_the_widget_
|
|||||||
->assertFormFieldExists('settings.text_size')
|
->assertFormFieldExists('settings.text_size')
|
||||||
->assertFormFieldExists('settings.palette');
|
->assertFormFieldExists('settings.palette');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beim Einspielen der Migrationen speichert der Seeder eine Seite, bevor site_settings existiert. In PostgreSQL bricht eine
|
||||||
|
* dort fehlgeschlagene Abfrage die ganze Transaktion ab (SQLSTATE 25P02), auch wenn der Fehler abgefangen wird; die CI fand
|
||||||
|
* das erst beim Wegwerf-Postgres. Darum darf die Palette ohne Tabelle gar nicht abgefragt werden.
|
||||||
|
*/
|
||||||
|
public function test_saving_a_widget_before_the_settings_table_exists_runs_no_query_against_it(): void
|
||||||
|
{
|
||||||
|
Schema::drop('site_settings');
|
||||||
|
DesignPalette::flush();
|
||||||
|
$queries = [];
|
||||||
|
// Vor der Ausführung mitschneiden: Eine fehlgeschlagene Abfrage löst QueryExecuted nie aus, und sie ist genau der Fehler.
|
||||||
|
DB::beforeExecuting(function (string $sql) use (&$queries): void {
|
||||||
|
$queries[] = $sql;
|
||||||
|
});
|
||||||
|
|
||||||
|
$saved = app(WidgetRegistry::class)->normalize([['id' => null, 'type' => 'heading', 'v' => 2, 'variant' => 'standard', 'settings' => [], 'data' => ['heading' => 'Titel'], 'refs' => []]]);
|
||||||
|
|
||||||
|
$this->assertCount(1, $saved);
|
||||||
|
$this->assertSame([], DesignPalette::slots());
|
||||||
|
$this->assertSame([], array_filter($queries, fn (string $sql): bool => str_contains($sql, 'site_settings') && ! str_contains($sql, 'sqlite_master')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user