Skip to content

Commit 13f8f86

Browse files
LukeTowersclaude
andcommitted
Guard against overlapping reorder requests; drop dead pivot guards
- Ignore further drops while a reorder request is in flight, so rapid successive drags can't race and persist a stale order (the response that lands last would otherwise win). - Remove the `$record->pivot` null guards in applyDeferredRelationOrder: records from a sortable belongsToMany/morphToMany/morphedByMany relation always carry a hydrated pivot, verified in both new-parent and existing-parent deferred/orphan modes, so the guards were unreachable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 690e905 commit 13f8f86

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

modules/backend/behaviors/RelationController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,13 @@ protected function applyDeferredRelationOrder($records)
622622
}
623623

624624
foreach ($records as $record) {
625-
if ($record->pivot && array_key_exists($record->getKey(), $map)) {
625+
if (array_key_exists($record->getKey(), $map)) {
626626
$record->pivot->{$column} = $map[$record->getKey()];
627627
}
628628
}
629629

630630
return $records->sortBy(function ($record) use ($column) {
631+
// Deferred records not yet assigned an order sort to the end.
631632
return $record->pivot->{$column} ?? PHP_INT_MAX;
632633
})->values();
633634
}

0 commit comments

Comments
 (0)