processLogEntries: skip incomplete entries instead of throwing
Per the spec's error-handling table, entries missing timestamp or details.title should be skipped (logged via consoleLog) and the loop should continue processing the rest. Previously the function threw LogEntryIncompleteException and aborted the entire batch, which would take down the whole UI when a single malformed entry was returned.
This commit is contained in:
@@ -117,9 +117,6 @@ function validateApiResponse($responseData) {
|
|||||||
* @param PDOStatement $insertStmt A prepared statement for the idempotent
|
* @param PDOStatement $insertStmt A prepared statement for the idempotent
|
||||||
* insert (`INSERT … ON CONFLICT(id) DO NOTHING`)
|
* insert (`INSERT … ON CONFLICT(id) DO NOTHING`)
|
||||||
*
|
*
|
||||||
* @throws LogEntryIncompleteException If a vault entry is missing timestamp
|
|
||||||
* or details.title
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function processLogEntries($logEntries, $user, $insertStmt) {
|
function processLogEntries($logEntries, $user, $insertStmt) {
|
||||||
@@ -146,9 +143,8 @@ function processLogEntries($logEntries, $user, $insertStmt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($timestamp === null || $description === null) {
|
if ($timestamp === null || $description === null) {
|
||||||
throw new LogEntryIncompleteException(
|
consoleLog('Skipping entry ' . $id . ' missing timestamp or details.title: ' . print_r($entry, true));
|
||||||
"Entry $id missing timestamp or details.title."
|
continue;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$insertStmt->bindValue(':id', $id);
|
$insertStmt->bindValue(':id', $id);
|
||||||
|
|||||||
Reference in New Issue
Block a user