Skip to content

Commit f6408cd

Browse files
authored
Merge pull request appwrite#7134 from appwrite/fix-recreate-repositories-documents
Fix patch script, make errors silent
2 parents 29cd164 + 1c4fea0 commit f6408cd

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/Appwrite/Platform/Tasks/patchRecreateRepositoriesDocuments.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ public function action($after, $projectId, Database $dbForConsole, callable $get
3737
$startTime = microtime(true);
3838

3939
if (!empty($projectId)) {
40-
$project = $dbForConsole->getDocument('projects', $projectId);
41-
$dbForProject = call_user_func($getProjectDB, $project);
42-
$this->recreateRepositories($dbForConsole, $dbForProject, $project);
40+
try {
41+
$project = $dbForConsole->getDocument('projects', $projectId);
42+
$dbForProject = call_user_func($getProjectDB, $project);
43+
$this->recreateRepositories($dbForConsole, $dbForProject, $project);
44+
} catch (\Throwable $th) {
45+
Console::error("Unexpected error occured with Project ID {$projectId}");
46+
Console::error('[Error] Type: ' . get_class($th));
47+
Console::error('[Error] Message: ' . $th->getMessage());
48+
Console::error('[Error] File: ' . $th->getFile());
49+
Console::error('[Error] Line: ' . $th->getLine());
50+
}
4351
} else {
4452
$queries = [];
4553
if (!empty($after)) {
@@ -50,8 +58,18 @@ public function action($after, $projectId, Database $dbForConsole, callable $get
5058
Console::info("Iterating all projects");
5159
}
5260
$this->foreachDocument($dbForConsole, 'projects', $queries, function (Document $project) use ($getProjectDB, $dbForConsole) {
53-
$dbForProject = call_user_func($getProjectDB, $project);
54-
$this->recreateRepositories($dbForConsole, $dbForProject, $project);
61+
$projectId = $project->getId();
62+
63+
try {
64+
$dbForProject = call_user_func($getProjectDB, $project);
65+
$this->recreateRepositories($dbForConsole, $dbForProject, $project);
66+
} catch (\Throwable $th) {
67+
Console::error("Unexpected error occured with Project ID {$projectId}");
68+
Console::error('[Error] Type: ' . get_class($th));
69+
Console::error('[Error] Message: ' . $th->getMessage());
70+
Console::error('[Error] File: ' . $th->getFile());
71+
Console::error('[Error] Line: ' . $th->getLine());
72+
}
5573
});
5674
}
5775

0 commit comments

Comments
 (0)