#4781: the bulk merged-repair is on the record too

MergedTicketRepair::repairAll() re-marks tickets as merged (permanently
read-only) per model instead of with one builder update, so each frozen
ticket gets its own Changes-log entry — the same as the per-ticket button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
central-worker-8
2026-10-19 05:16:23 -07:00
parent adcb02863d
commit 9cc2e59b45

View File

@@ -84,17 +84,22 @@ class MergedTicketRepair
*/ */
public static function repairAll(string $by): int public static function repairAll(string $by): int
{ {
$numbers = Ticket::query()->inconsistentlyMerged()->pluck('number')->all(); $tickets = Ticket::query()->inconsistentlyMerged()->orderBy('id')->get();
if ($numbers === []) { if ($tickets->isEmpty()) {
Log::info("[ticketing] #938 merged-ticket repair ({$by}): nothing to repair."); Log::info("[ticketing] #938 merged-ticket repair ({$by}): nothing to repair.");
return 0; return 0;
} }
$changed = Ticket::query()->inconsistentlyMerged()->update([ // Per model, not one builder update (#4781/#4807): `merged` makes a ticket
'status' => Ticket::STATUS_MERGED, // permanently read-only, and a bulk statement would freeze it with nothing
]); // on the Changes log — while repair() below, the same change one ticket at
// a time, is recorded.
$tickets->each(fn (Ticket $ticket) => $ticket->forceFill(['status' => Ticket::STATUS_MERGED])->save());
$numbers = $tickets->pluck('number')->all();
$changed = $tickets->count();
// The numbers, not just the count. These rows are being made read-only, // The numbers, not just the count. These rows are being made read-only,
// and "which ones" is the question the office will ask afterwards. // and "which ones" is the question the office will ask afterwards.