From 9e63702387a0e6943f2ea53558e8ae50a51f1f94 Mon Sep 17 00:00:00 2001 From: Josef Citrine Date: Sat, 10 Dec 2016 16:39:58 +0000 Subject: [PATCH] Fixed genre deletion --- app/Jobs/DeleteGenre.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/Jobs/DeleteGenre.php b/app/Jobs/DeleteGenre.php index 30a33a71..6aed5171 100644 --- a/app/Jobs/DeleteGenre.php +++ b/app/Jobs/DeleteGenre.php @@ -47,10 +47,6 @@ class DeleteGenre extends Job implements ShouldQueue $this->executingUser = Auth::user(); $this->genreToDelete = $genreToDelete; $this->destinationGenre = $destinationGenre; - - // The genre is deleted synchronously before the job is executed in - // order to prevent race conditions. - $this->genreToDelete->delete(); } /** @@ -67,14 +63,14 @@ class DeleteGenre extends Job implements ShouldQueue // This is done instead of a single UPDATE query in order to // generate revision logs for the change. - $this->genreToDelete->tracks()->chunk(200, function ($tracks) { - foreach ($tracks as $track) { - /** @var Track $track */ + $this->genreToDelete->tracks()->each(function ($track) { + /** @var Track $track */ - $track->genre_id = $this->destinationGenre->id; - $track->save(); - $track->updateTags(); - } + $track->genre_id = $this->destinationGenre->id; + $track->save(); + $track->updateTags(); }); + + $this->genreToDelete->delete(); } }