Răsfoiți Sursa

Merge pull request #3122 from idanoo/hashtag_unique_constraint_fix

Fix for firstOrCreate failing hashtags with case differences on name column
daniel 3 ani în urmă
părinte
comite
3ee699ba3f
1 a modificat fișierele cu 7 adăugiri și 3 ștergeri
  1. 7 3
      app/Jobs/StatusPipeline/StatusEntityLexer.php

+ 7 - 3
app/Jobs/StatusPipeline/StatusEntityLexer.php

@@ -107,9 +107,13 @@ class StatusEntityLexer implements ShouldQueue
 			}
 			DB::transaction(function () use ($status, $tag) {
 				$slug = str_slug($tag, '-', false);
-				$hashtag = Hashtag::firstOrCreate(
-					['name' => $tag, 'slug' => $slug]
-				);
+				$hashtag = Hashtag::where('slug', $slug)->first();
+				if (!$hashtag) {
+					$hashtag = Hashtag::create(
+						['name' => $tag, 'slug' => $slug]
+					);
+				}
+
 				StatusHashtag::firstOrCreate(
 					[
 						'status_id' => $status->id,