[14.x] Mark batches allowing failures as finished once all jobs have run
Fixes #61835. Resubmitting #62207 against 14.x, since it was closed on 13.x as a possible breaking change for a patch release.
A batch that allows failures runs its finally() callbacks once every job has either succeeded or failed, but finished_at is only set when every job succeeded. So as soon as one job fails, the batch never reports finished(), and queue:prune-batches only removes it through --unfinished.
This sets finished_at at the same point finally() runs, so finally() now receives a finished batch.
Unchanged on purpose:
pending_jobs/failed_jobs, soqueue:retry-batchstill works. A successful retry goes through the normal success path and updatesfinished_atagain.then()still only runs when every job succeeded.BatchFinishedis still only dispatched on full success, so existing listeners don't start firing for failed batches.
Upgrade note: for batches using allowFailures(), finished() now returns true once every job has run, even if some failed. Code that used finished() to mean "every job succeeded" should check $batch->pendingJobs === 0 or ! $batch->hasFailures() instead.