fix: attempt to lock for update (#976)

This commit is contained in:
Kyrch
2025-10-17 15:30:17 -03:00
committed by GitHub
parent e9246d0e0d
commit 1aa4d020a8
4 changed files with 9 additions and 4 deletions
@@ -25,7 +25,7 @@ class DestroyTrackAction
// Lock tracks to prevent race conditions.
Playlist::query()->whereKey($playlist->getKey())->lockForUpdate()->first();
$playlist->tracks()->getQuery()->lockForUpdate()->count();
$playlist->tracks()->select(PlaylistTrack::ATTRIBUTE_ID)->lockForUpdate()->get();
$removeAction = new RemoveTrackAction();
@@ -36,7 +36,7 @@ class StoreTrackAction
// Lock tracks to prevent race conditions.
Playlist::query()->whereKey($playlist->getKey())->lockForUpdate()->first();
$playlist->tracks()->getQuery()->lockForUpdate()->count();
$playlist->tracks()->select(PlaylistTrack::ATTRIBUTE_ID)->lockForUpdate()->get();
/** @var StoreAction<PlaylistTrack> $storeAction */
$storeAction = new StoreAction();
@@ -33,7 +33,7 @@ class UpdateTrackAction
// Lock tracks to prevent race conditions.
Playlist::query()->whereKey($playlist->getKey())->lockForUpdate()->first();
$playlist->tracks()->getQuery()->lockForUpdate()->count();
$playlist->tracks()->select(PlaylistTrack::ATTRIBUTE_ID)->lockForUpdate()->get();
/** @var UpdateAction<PlaylistTrack> $updateAction */
$updateAction = new UpdateAction();
+6 -1
View File
@@ -79,10 +79,15 @@ class DiscordEmbedField implements Arrayable, JsonSerializable
}
// Encode to json for all other non-empty scalar values
if ((is_scalar($value) || $value instanceof Stringable) && Str::length($value) > 0) {
if (is_scalar($value) && Str::length($value) > 0) {
return strval($value);
}
// Convert Stringable objects to string
if ($value instanceof Stringable && filled($value)) {
return (string) $value;
}
return self::DEFAULT_FIELD_VALUE;
}
}