Skip to content

Commit 14c4e9e

Browse files
committed
chore: Replace doctrine's deprecated fetchAll() with the new methods
Change-Id: Ia8bca0e1ea30d7dbd1f17c767089cb7350026d82
1 parent 774a544 commit 14c4e9e

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
@@ -1030,13 +1030,13 @@ public function belongsToGroup(string $code): bool
10301030
SQL;
10311031

10321032
$stmt = $this->prepareRawSQL($sql);
1033-
$stmt->execute(
1033+
$res = $stmt->execute(
10341034
[
10351035
'member_id' => $this->getId(),
10361036
'code' => trim($code),
10371037
]
10381038
);
1039-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
1039+
$res = $res->fetchFirstColumn();
10401040
return intval($res[0]) > 0;
10411041
} catch (\Exception $ex) {
10421042

@@ -1160,13 +1160,13 @@ public function getFavoritesEventsIds(Summit $summit)
11601160
SQL;
11611161

11621162
$stmt = $this->prepareRawSQL($sql);
1163-
$stmt->execute(
1163+
$res = $stmt->execute(
11641164
[
11651165
'member_id' => $this->getId(),
11661166
'summit_id' => $summit->getId(),
11671167
]
11681168
);
1169-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
1169+
return $res->fetchAllNumeric();
11701170
}
11711171

11721172
/**
@@ -1331,13 +1331,13 @@ public function getScheduledEventsIds(Summit $summit)
13311331
SQL;
13321332

13331333
$stmt = $this->prepareRawSQL($sql);
1334-
$stmt->execute(
1334+
$res = $stmt->execute(
13351335
[
13361336
'member_id' => $this->getId(),
13371337
'summit_id' => $summit->getId(),
13381338
]
13391339
);
1340-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
1340+
return $res->fetchAllNumeric();
13411341
}
13421342

13431343
/**
@@ -1818,13 +1818,13 @@ public function getSponsorMembershipIds(Summit $summit): array
18181818
SQL;
18191819

18201820
$stmt = $this->prepareRawSQL($sql);
1821-
$stmt->execute(
1821+
$res = $stmt->execute(
18221822
[
18231823
'member_id' => $this->getId(),
18241824
'summit_id' => $summit->getId(),
18251825
]
18261826
);
1827-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
1827+
return $res->fetchAllNumeric();
18281828
}
18291829

18301830
public function hasSponsorMembershipsFor(Summit $summit, Sponsor $sponsor = null): bool
@@ -1851,8 +1851,8 @@ public function hasSponsorMembershipsFor(Summit $summit, Sponsor $sponsor = null
18511851
}
18521852

18531853
$stmt = $this->prepareRawSQL($sql);
1854-
$stmt->execute($params);
1855-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
1854+
$res = $stmt->execute($params);
1855+
$res = $res->fetchFirstColumn();
18561856
return intval($res[0]) > 0;
18571857
} catch (\Exception $ex) {
18581858
return false;
@@ -2071,13 +2071,13 @@ public function hasPermissionForOnGroup(Summit $summit, string $groupSlug): bool
20712071
SQL;
20722072

20732073
$stmt = $this->prepareRawSQL($sql);
2074-
$stmt->execute(
2074+
$res = $stmt->execute(
20752075
[
20762076
'member_id' => $this->getId(),
20772077
'summit_id' => $summit->getId()
20782078
]
20792079
);
2080-
$allowed_summits = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2080+
$allowed_summits = $res->fetchAllNumeric();
20812081
return count($allowed_summits) > 0 && $this->isOnGroup($groupSlug);
20822082
}
20832083

@@ -2098,13 +2098,13 @@ public function hasPermissionFor(Summit $summit): bool
20982098
SQL;
20992099

21002100
$stmt = $this->prepareRawSQL($sql);
2101-
$stmt->execute(
2101+
$res = $stmt->execute(
21022102
[
21032103
'member_id' => $this->getId(),
21042104
'summit_id' => $summit->getId()
21052105
]
21062106
);
2107-
$allowed_summits = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2107+
$allowed_summits = $res->fetchAllNumeric();
21082108
return count($allowed_summits) > 0;
21092109
}
21102110

@@ -2126,15 +2126,15 @@ public function getPaidSummitTicketsIds(Summit $summit)
21262126
SQL;
21272127

21282128
$stmt = $this->prepareRawSQL($sql);
2129-
$stmt->execute(
2129+
$res = $stmt->execute(
21302130
[
21312131
'member_id' => $this->getId(),
21322132
'member_email' => $this->email,
21332133
'ticket_status' => IOrderConstants::PaidStatus,
21342134
'summit_id' => $summit->getId(),
21352135
]
21362136
);
2137-
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
2137+
return $res->fetchAllNumeric();
21382138
}
21392139

21402140
/**
@@ -2396,11 +2396,11 @@ public function getElectionApplicationsCountFor(Election $election): int
23962396
C.CandidateID = :candidate_id
23972397
SQL;
23982398
$stmt = $this->prepareRawSQL($sql);
2399-
$stmt->execute([
2399+
$res = $stmt->execute([
24002400
'election_id' => $election->getId(),
24012401
'candidate_id' => $this->id
24022402
]);
2403-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2403+
$res = $res->fetchFirstColumn();
24042404
return count($res) > 0 ? $res[0] : 0;
24052405
} catch (\Exception $ex) {
24062406
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
@@ -2231,12 +2231,12 @@ public function getTrackChairAvgScoresPerRakingType(): array
22312231

22322232
try {
22332233
$stmt = $this->prepareRawSQL($query);
2234-
$stmt->execute(
2234+
$res = $stmt->execute(
22352235
[
22362236
'presentation_id' => $this->getId(),
22372237
]
22382238
);
2239-
$res = $stmt->fetchAll();
2239+
$res = $res->fetchAllAssociative();
22402240
$res = count($res) > 0 ? $res : [];
22412241
return $res;
22422242
} catch (\Exception $ex) {
@@ -2265,12 +2265,12 @@ public function getTrackChairAvgScore(): float
22652265
SQL;
22662266
try {
22672267
$stmt = $this->prepareRawSQL($query);
2268-
$stmt->execute(
2268+
$res = $stmt->execute(
22692269
[
22702270
'presentation_id' => $this->getId(),
22712271
]
22722272
);
2273-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2273+
$res = $res->fetchFirstColumn();
22742274
$score = count($res) > 0 ? $res[0] : 0;
22752275
return floatval($score);
22762276
} catch (\Exception $ex) {
@@ -2308,13 +2308,13 @@ public function getTrackChairScoreFor(SummitTrackChair $trackChair): float
23082308
SQL;
23092309
try {
23102310
$stmt = $this->prepareRawSQL($query);
2311-
$stmt->execute(
2311+
$res = $stmt->execute(
23122312
[
23132313
'presentation_id' => $this->getId(),
23142314
'track_chair_id' => $trackChair->getId()
23152315
]
23162316
);
2317-
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
2317+
$res = $res->fetchFirstColumn();
23182318
$score = count($res) > 0 ? $res[0] : 0;
23192319
return floatval($score);
23202320
} 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)