Skip to content

Commit 3a85c6b

Browse files
committed
chore: Replace doctrine's deprecated fetchAll() with the new methods
Change-Id: Ia8bca0e1ea30d7dbd1f17c767089cb7350026d82
1 parent 5c6c976 commit 3a85c6b

18 files changed

+132
-131
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
php artisan db:create_test_db --schema=config
103103
php artisan db:create_test_db --schema=model
104104
php artisan doctrine:migrations:migrate --no-interaction --em model
105+
./update_doctrine.sh
105106
echo "running OAuth2SummitApiTest"
106107
vendor/bin/phpunit --filter "OAuth2SummitApiTest" --log-junit results_summit_api_test.xml
107108
echo "running OAuth2SummitEventsApiTest"

app/Models/Foundation/Main/Member.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,13 @@ public function belongsToGroup(string $code): bool
979979
SQL;
980980

981981
$stmt = $this->prepareRawSQL($sql);
982-
$stmt->execute(
982+
$res = $stmt->execute(
983983
[
984984
'member_id' => $this->getId(),
985985
'code' => trim($code),
986986
]
987987
);
988-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
988+
$res = $res->fetchFirstColumn();
989989
return intval($res[0]) > 0;
990990
} catch (\Exception $ex) {
991991

@@ -1109,13 +1109,13 @@ public function getFavoritesEventsIds(Summit $summit)
11091109
SQL;
11101110

11111111
$stmt = $this->prepareRawSQL($sql);
1112-
$stmt->execute(
1112+
$res = $stmt->execute(
11131113
[
11141114
'member_id' => $this->getId(),
11151115
'summit_id' => $summit->getId(),
11161116
]
11171117
);
1118-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
1118+
return $res->fetchAllNumeric();
11191119
}
11201120

11211121
/**
@@ -1280,13 +1280,13 @@ public function getScheduledEventsIds(Summit $summit)
12801280
SQL;
12811281

12821282
$stmt = $this->prepareRawSQL($sql);
1283-
$stmt->execute(
1283+
$res = $stmt->execute(
12841284
[
12851285
'member_id' => $this->getId(),
12861286
'summit_id' => $summit->getId(),
12871287
]
12881288
);
1289-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
1289+
return $res->fetchAllNumeric();
12901290
}
12911291

12921292
/**
@@ -1767,13 +1767,13 @@ public function getSponsorMembershipIds(Summit $summit): array
17671767
SQL;
17681768

17691769
$stmt = $this->prepareRawSQL($sql);
1770-
$stmt->execute(
1770+
$res = $stmt->execute(
17711771
[
17721772
'member_id' => $this->getId(),
17731773
'summit_id' => $summit->getId(),
17741774
]
17751775
);
1776-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
1776+
return $res->fetchAllNumeric();
17771777
}
17781778

17791779
public function hasSponsorMembershipsFor(Summit $summit, Sponsor $sponsor = null): bool
@@ -1800,8 +1800,8 @@ public function hasSponsorMembershipsFor(Summit $summit, Sponsor $sponsor = null
18001800
}
18011801

18021802
$stmt = $this->prepareRawSQL($sql);
1803-
$stmt->execute($params);
1804-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
1803+
$res = $stmt->execute($params);
1804+
$res = $res->fetchFirstColumn();
18051805
return intval($res[0]) > 0;
18061806
} catch (\Exception $ex) {
18071807
return false;
@@ -2020,13 +2020,13 @@ public function hasPermissionForOnGroup(Summit $summit, string $groupSlug): bool
20202020
SQL;
20212021

20222022
$stmt = $this->prepareRawSQL($sql);
2023-
$stmt->execute(
2023+
$res = $stmt->execute(
20242024
[
20252025
'member_id' => $this->getId(),
20262026
'summit_id' => $summit->getId()
20272027
]
20282028
);
2029-
$allowed_summits = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2029+
$allowed_summits = $res->fetchAllNumeric();
20302030
return count($allowed_summits) > 0 && $this->isOnGroup($groupSlug);
20312031
}
20322032

@@ -2047,13 +2047,13 @@ public function hasPermissionFor(Summit $summit): bool
20472047
SQL;
20482048

20492049
$stmt = $this->prepareRawSQL($sql);
2050-
$stmt->execute(
2050+
$res = $stmt->execute(
20512051
[
20522052
'member_id' => $this->getId(),
20532053
'summit_id' => $summit->getId()
20542054
]
20552055
);
2056-
$allowed_summits = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2056+
$allowed_summits = $res->fetchAllNumeric();
20572057
return count($allowed_summits) > 0;
20582058
}
20592059

@@ -2075,15 +2075,15 @@ public function getPaidSummitTicketsIds(Summit $summit)
20752075
SQL;
20762076

20772077
$stmt = $this->prepareRawSQL($sql);
2078-
$stmt->execute(
2078+
$res = $stmt->execute(
20792079
[
20802080
'member_id' => $this->getId(),
20812081
'member_email' => $this->email,
20822082
'ticket_status' => IOrderConstants::PaidStatus,
20832083
'summit_id' => $summit->getId(),
20842084
]
20852085
);
2086-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
2086+
return $res->fetchAllNumeric();
20872087
}
20882088

20892089
/**
@@ -2345,11 +2345,11 @@ public function getElectionApplicationsCountFor(Election $election): int
23452345
C.CandidateID = :candidate_id
23462346
SQL;
23472347
$stmt = $this->prepareRawSQL($sql);
2348-
$stmt->execute([
2348+
$res = $stmt->execute([
23492349
'election_id' => $election->getId(),
23502350
'candidate_id' => $this->id
23512351
]);
2352-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2352+
$res = $res->fetchFirstColumn();
23532353
return count($res) > 0 ? $res[0] : 0;
23542354
} catch (\Exception $ex) {
23552355
Log::warning($ex);

app/Models/Foundation/Main/Strategies/MemberSummitStrategy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public function getAllAllowedSummitIds(): array
4545
SQL;
4646

4747
$stmt = $em->getConnection()->prepare($sql);
48-
$stmt->execute(
48+
$res = $stmt->execute(
4949
[
5050
'member_id' => $this->member_id,
5151
]
5252
);
53-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
53+
return $res->fetchAllNumeric();
5454
}
5555

5656
/**
@@ -72,13 +72,13 @@ public function isSummitAllowed(Summit $summit): bool
7272
SQL;
7373

7474
$stmt = $em->getConnection()->prepare($sql);
75-
$stmt->execute(
75+
$res = $stmt->execute(
7676
[
7777
'member_id' => $this->member_id,
7878
'summit_id' => $summit->getId(),
7979
]
8080
);
81-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
81+
$res = $res->fetchFirstColumn();
8282
return intval($res[0]) > 0;
8383
} catch (\Exception $ex) {
8484
return false;

app/Models/Foundation/Main/Strategies/SponsorMemberSummitStrategy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function getAllAllowedSummitIds(): array
4343
SQL;
4444

4545
$stmt = $em->getConnection()->prepare($sql);
46-
$stmt->execute(
46+
$res = $stmt->execute(
4747
[
4848
'member_id' => $this->member_id,
4949
]
5050
);
51-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
51+
return $res->fetchAllNumeric();
5252
}
5353

5454
/**
@@ -68,13 +68,13 @@ public function isSummitAllowed(Summit $summit): bool
6868
SQL;
6969

7070
$stmt = $em->getConnection()->prepare($sql);
71-
$stmt->execute(
71+
$res = $stmt->execute(
7272
[
7373
'member_id' => $this->member_id,
7474
'summit_id' => $summit->getId(),
7575
]
7676
);
77-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
77+
$res = $res->fetchFirstColumn();
7878
return intval($res[0]) > 0;
7979
} catch (\Exception $ex) {
8080
return false;

app/Models/Foundation/Main/SummitAdministratorPermissionGroup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ public function getMembersIds(): array
117117
SQL;
118118

119119
$stmt = $this->prepareRawSQL($sql);
120-
$stmt->execute(
120+
$res = $stmt->execute(
121121
[
122122
'group_id' => $this->getId(),
123123
]
124124
);
125-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
125+
return $res->fetchAllNumeric();
126126

127127
}
128128

@@ -158,12 +158,12 @@ public function getSummitsIds(): array
158158
SQL;
159159

160160
$stmt = $this->prepareRawSQL($sql);
161-
$stmt->execute(
161+
$res = $stmt->execute(
162162
[
163163
'group_id' => $this->getId(),
164164
]
165165
);
166-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
166+
return $res->fetchAllNumeric();
167167

168168
}
169169

app/Models/Foundation/Summit/Events/Presentations/Presentation.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,12 +2228,12 @@ public function getTrackChairAvgScoresPerRakingType(): array
22282228

22292229
try {
22302230
$stmt = $this->prepareRawSQL($query);
2231-
$stmt->execute(
2231+
$res = $stmt->execute(
22322232
[
22332233
'presentation_id' => $this->getId(),
22342234
]
22352235
);
2236-
$res = $stmt->fetchAll();
2236+
$res = $res->fetchAllAssociative();
22372237
$res = count($res) > 0 ? $res : [];
22382238
return $res;
22392239
} catch (\Exception $ex) {
@@ -2262,12 +2262,12 @@ public function getTrackChairAvgScore(): float
22622262
SQL;
22632263
try {
22642264
$stmt = $this->prepareRawSQL($query);
2265-
$stmt->execute(
2265+
$res = $stmt->execute(
22662266
[
22672267
'presentation_id' => $this->getId(),
22682268
]
22692269
);
2270-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2270+
$res = $res->fetchFirstColumn();
22712271
$score = count($res) > 0 ? $res[0] : 0;
22722272
return floatval($score);
22732273
} catch (\Exception $ex) {
@@ -2305,13 +2305,13 @@ public function getTrackChairScoreFor(SummitTrackChair $trackChair): float
23052305
SQL;
23062306
try {
23072307
$stmt = $this->prepareRawSQL($query);
2308-
$stmt->execute(
2308+
$res = $stmt->execute(
23092309
[
23102310
'presentation_id' => $this->getId(),
23112311
'track_chair_id' => $trackChair->getId()
23122312
]
23132313
);
2314-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2314+
$res = $res->fetchFirstColumn();
23152315
$score = count($res) > 0 ? $res[0] : 0;
23162316
return floatval($score);
23172317
} catch (\Exception $ex) {

app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,13 @@ public function belongsToGroup(int $group_id):bool{
569569

570570

571571
$stmt = $this->prepareRawSQL($sql);
572-
$stmt->execute(
572+
$res = $stmt->execute(
573573
[
574574
'track_id' => $this->getId(),
575575
'group_id' => $group_id
576576
]
577577
);
578-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
578+
$res = $res->fetchFirstColumn();
579579
$res = count($res) > 0 ? $res[0] : 0;
580580
return $res > 0;
581581
}

app/Models/Foundation/Summit/Events/Presentations/PresentationCategoryGroup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,12 @@ public function canEmitAttendeeVote(SummitAttendee $attendee): bool
352352
AND PresentationCategoryGroup_Categories.PresentationCategoryGroupID = :id
353353
SQL;
354354
$stmt = $this->prepareRawSQL($sql);
355-
$stmt->execute
355+
$res = $stmt->execute
356356
([
357357
'id' => $this->id,
358358
'attendee_id' => $attendee->getId(),
359359
]);
360-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
360+
$res = $res->fetchFirstColumn();
361361
$res = count($res) > 0 ? $res[0] : 0;
362362
$res = !is_null($res) ? $res : 0;
363363
Log::debug

app/Models/Foundation/Summit/Events/Presentations/PresentationType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public static function IsPresentationEventType(Summit $summit, $type)
138138
AND SummitEventType.Type = :type
139139
SQL;
140140
$stmt = self::prepareRawSQLStatic($sql);
141-
$stmt->execute(['summit_id' => $summit->getId(), 'type' => $type]);
142-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
141+
$res = $stmt->execute(['summit_id' => $summit->getId(), 'type' => $type]);
142+
$res = $res->fetchFirstColumn();
143143
return count($res) > 0;
144144
} catch (\Exception $ex) {
145145

app/Models/Foundation/Summit/Registration/Attendees/SummitAttendee.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,13 @@ public function getExtraQuestionAnswerValueByQuestion(SummitOrderExtraQuestionTy
693693
WHERE SummitOrderExtraQuestionAnswer.SummitAttendeeID = :owner_id AND ExtraQuestionAnswer.QuestionID = :question_id
694694
SQL;
695695
$stmt = $this->prepareRawSQL($sql);
696-
$stmt->execute(
696+
$res = $stmt->execute(
697697
[
698698
'owner_id' => $this->getId(),
699699
'question_id' => $question->getId()
700700
]
701701
);
702-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
702+
$res = $res->fetchFirstColumn();
703703
$res = count($res) > 0 ? $res[0] : null;
704704
return !is_null($res) ? $res : null;
705705
} catch (\Exception $ex) {
@@ -1162,8 +1162,8 @@ public function getBoughtTicketTypes(): array
11621162
GROUP BY OwnerID, TicketTypeID;
11631163
SQL;
11641164
$stmt = $this->prepareRawSQL($sql);
1165-
$stmt->execute(['owner_id' => $this->id]);
1166-
$res = $stmt->fetchAll();
1165+
$res = $stmt->execute(['owner_id' => $this->id]);
1166+
$res = $res->fetchAllAssociative();
11671167
$res = count($res) > 0 ? $res : [];
11681168
if (count($res) > 0) {
11691169
$res = array_map(function ($e) {

0 commit comments

Comments
 (0)