fix(import): dedupe tags via Tag::findFromString (name is JSON translatable)
Build and Deploy / verify (push) Failing after 30m11s
Build and Deploy / deploy (push) Skipped

This commit is contained in:
2026-10-12 12:44:39 +00:00
parent 6adfacc4e5
commit 86effba075
+3 -1
View File
@@ -340,7 +340,9 @@ class SablogImport extends Command
continue; continue;
} }
$tag = Tag::query()->where('name', $tagName)->where('type', 'post')->first(); // spatie/tags 的 name 是 JSON 翻译字段,直接 where('name', ...) 匹配不到,
// 必须用 findFromString(内部按 locale 查询 JSON 键),否则每次导入都重复建标签
$tag = Tag::findFromString($tagName, 'post');
if (! $tag) { if (! $tag) {
$tag = new Tag(['name' => $tagName, 'type' => 'post']); $tag = new Tag(['name' => $tagName, 'type' => 'post']);
$tag->slug = SlugGenerator::make($tagName, 'tags', 'slug', fallback: 'tag-'.crc32($tagName)); $tag->slug = SlugGenerator::make($tagName, 'tags', 'slug', fallback: 'tag-'.crc32($tagName));