@@ -864,32 +864,23 @@ public function internalErrorAction(Request $request): ?int
864
864
865
865
if ($ field_name !== null ) {
866
866
// Disable any outstanding judgetasks with the same script that have not been claimed yet.
867
- $ this ->em ->wrapInTransaction (function (EntityManager $ em ) use ($ field_name , $ disabled_id , $ error ) {
868
- $ judgingids = $ em ->getConnection ()->executeQuery (
869
- 'SELECT DISTINCT jobid '
870
- . ' FROM judgetask '
871
- . ' WHERE ' . $ field_name . ' = :id '
872
- . ' AND judgehostid IS NULL '
873
- . ' AND valid = 1 ' ,
874
- [
875
- 'id ' => $ disabled_id ,
876
- ]
877
- )->fetchFirstColumn ();
878
- $ judgings = $ em ->getRepository (Judging::class)->findBy (['judgingid ' => $ judgingids ]);
879
- foreach ($ judgings as $ judging ) {
880
- /** @var Judging $judging */
881
- $ judging ->setInternalError ($ error );
882
- }
883
- $ em ->flush ();
884
- $ em ->getConnection ()->executeStatement (
885
- 'UPDATE judgetask SET valid=0 '
886
- . ' WHERE ' . $ field_name . ' = :id '
887
- . ' AND judgehostid IS NULL ' ,
888
- [
889
- 'id ' => $ disabled_id ,
890
- ]
891
- );
892
- });
867
+ $ rows = $ this ->em ->createQueryBuilder ()
868
+ ->update (Judging::class, 'j ' )
869
+ ->leftJoin (JudgeTask::class, 'jt ' )
870
+ ->set ('j.internal_error ' , $ error )
871
+ ->set ('jt.valid ' , 0 )
872
+ ->where ('jt. ' . $ field_name . ' = :id ' )
873
+ ->andWhere ('j.internal_error IS NULL ' )
874
+ ->andWhere ('jt.judgehost_id IS NULL ' )
875
+ ->andWhere ('jt.valid = 1 ' )
876
+ ->setParameter ('id ' , $ disabled_id )
877
+ ->distinct ()
878
+ ->getQuery ()
879
+ ->getArrayResult ();
880
+
881
+ if ($ rows == 0 ) {
882
+ // TODO, handle this case. Nothing was updated.
883
+ }
893
884
}
894
885
895
886
$ this ->dj ->setInternalError ($ disabled , $ contest , false );
0 commit comments