Skip to content

Commit 4ef7d28

Browse files
committed
bugfix
1 parent 3209881 commit 4ef7d28

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/GraphJS/Controllers/ForumController.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,14 @@ public function getThreads(Request $request, Response $response, Kernel $kernel)
199199

200200
foreach($everything as $thing) {
201201
if($thing instanceof Thread) {
202+
try {
203+
$author = $thing->edges()->in(Start::class)->current()->tail();
204+
}
205+
catch(\Error $e) {
206+
continue;
207+
}
202208
$contributors_x = [];
209+
$contributors_x[$author->id()->toString()] = $author;
203210
$contributors = array_map(
204211
function(User $u) : array
205212
{
@@ -218,26 +225,36 @@ function (string $key): bool {
218225
},array_map( function(Reply $r): User {
219226
return $r->tail()->node();
220227
}, $thing->getReplies()));
228+
$contributors[] = $author;
221229
foreach($contributors as $contributor) {
222230
foreach($contributor as $k=>$v) {
223231
if(!isset($contributors_x[$k]))
224232
$contributors_x[$k] = $v;
225233
}
226234
}
227-
unset($contributors);
228-
if(is_null($thing->edges()->in(Start::class)->current()))
235+
//unset($contributors);
236+
try {
237+
if(is_null($thing->edges()->in(Start::class)->current()))
238+
continue;
239+
}
240+
catch(\Error $e) {
241+
// either Exception or Error
242+
//error_log("there was an exception at ".$thing->id()->toString());
229243
continue;
244+
}
245+
catch(\Exception $e) {
246+
continue;
247+
}
230248
$threads[] = [
231249
"id" => (string) $thing->id(),
232250
"title" => $thing->getTitle(),
233-
"author" => (string) $thing->edges()->in(Start::class)->current()->tail()->id(),
251+
"author" => (string) $author->id(),
234252
"timestamp" => (string) $thing->getCreateTime(),
235253
"contributors" => $contributors_x
236254
];
237255
}
238256
}
239257

240-
241258
$threads_count = count($threads);
242259
$threads = array_values($this->paginate($threads, $params, 20));
243260

0 commit comments

Comments
 (0)