Skip to content

Commit a51dc6e

Browse files
committed
fix
1 parent 3fad6cf commit a51dc6e

3 files changed

Lines changed: 38 additions & 19 deletions

File tree

src/Repositories/EventRepository.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ public function insert(string $title): Event
119119
$stmt = $this->pdo->prepare('INSERT INTO ' . $this->prefix . 'widget_donation_goal_bar (charity_event_guid) VALUES (:guid)');
120120
$stmt->execute([':guid' => $guid]);
121121

122-
$stmt = $this->pdo->prepare('INSERT INTO ' . $this->prefix . 'widget_card (charity_event_guid, description) VALUES (:guid, "")');
123-
$stmt->execute([':guid' => $guid]);
122+
try {
123+
$stmt = $this->pdo->prepare('INSERT INTO ' . $this->prefix . 'widget_card (charity_event_guid, description) VALUES (:guid, "")');
124+
$stmt->execute([':guid' => $guid]);
125+
} catch (Exception $e) {
126+
// Table may not exist yet (migration not run) — skip silently
127+
}
124128

125129
$this->pdo->commit();
126130

@@ -158,8 +162,12 @@ public function delete(Event $event)
158162

159163
$query = 'DELETE FROM ' . $this->prefix . 'widget_card
160164
WHERE charity_event_guid = ?';
161-
$stmt = $this->pdo->prepare($query);
162-
$stmt->execute([$event->guid]);
165+
try {
166+
$stmt = $this->pdo->prepare($query);
167+
$stmt->execute([$event->guid]);
168+
} catch (Exception $e) {
169+
// Table may not exist yet — skip silently
170+
}
163171

164172
$query = 'DELETE FROM ' . $this->prefix . 'charity_event
165173
WHERE id = ?';

src/Repositories/StreamRepository.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ function insert($form_slug, $organization_slug, $title, $parent = null): Stream
142142

143143
$query = 'INSERT INTO ' . $this->prefix . 'widget_card (charity_stream_guid, description)
144144
VALUES (:guid, "")';
145-
$stmt = $this->pdo->prepare($query);
146-
$stmt->execute([
147-
':guid' => $guid
148-
]);
145+
try {
146+
$stmt = $this->pdo->prepare($query);
147+
$stmt->execute([':guid' => $guid]);
148+
} catch (Exception $e) {
149+
// Table may not exist yet (migration not run) — skip silently
150+
}
149151

150152
$this->pdo->commit();
151153

@@ -179,8 +181,12 @@ public function delete($stream)
179181

180182
$query = 'DELETE FROM ' . $this->prefix . 'widget_card
181183
WHERE charity_stream_guid = ?';
182-
$stmt = $this->pdo->prepare($query);
183-
$stmt->execute([$stream->guid]);
184+
try {
185+
$stmt = $this->pdo->prepare($query);
186+
$stmt->execute([$stream->guid]);
187+
} catch (Exception $e) {
188+
// Table may not exist yet — skip silently
189+
}
184190

185191
$query = 'DELETE FROM ' . $this->prefix . 'user_right
186192
WHERE id_charity_stream = ?';

src/Repositories/WidgetRepository.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,20 @@ public function updateEventDonationWidgetCacheData(string $eventGuid, array $dat
202202

203203
public function selectCardWidgetByGuid(?string $streamGuid, ?string $eventGuid): ?WidgetCard
204204
{
205-
$stmt = $this->pdo->prepare('
206-
SELECT *
207-
FROM ' . $this->prefix . 'widget_card
208-
WHERE charity_stream_guid = ?
209-
OR charity_event_guid = ?
210-
');
211-
$stmt->setFetchMode(PDO::FETCH_CLASS, WidgetCard::class);
212-
$stmt->execute([$streamGuid, $eventGuid]);
213-
return $stmt->fetch() ?: null;
205+
try {
206+
$stmt = $this->pdo->prepare('
207+
SELECT *
208+
FROM ' . $this->prefix . 'widget_card
209+
WHERE charity_stream_guid = ?
210+
OR charity_event_guid = ?
211+
');
212+
$stmt->setFetchMode(PDO::FETCH_CLASS, WidgetCard::class);
213+
$stmt->execute([$streamGuid, $eventGuid]);
214+
return $stmt->fetch() ?: null;
215+
} catch (Exception $e) {
216+
// Table may not exist yet (migration not run)
217+
return null;
218+
}
214219
}
215220

216221
public function insertCardWidget(?string $streamGuid, ?string $eventGuid): void

0 commit comments

Comments
 (0)