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