@@ -52,7 +52,7 @@ public function getById(int $id): EphemeralToken {
5252 }
5353
5454 /**
55- * @throws \ Exception
55+ * @throws Exception
5656 * @return EphemeralToken[]
5757 */
5858 public function getAll (): array {
@@ -64,6 +64,12 @@ public function getAll(): array {
6464 return $ this ->findEntities ($ qb );
6565 }
6666
67+
68+ /**
69+ * @param int $olderThan
70+ * @return EphemeralToken[]
71+ * @throws Exception
72+ */
6773 public function getOlderThan ($ olderThan ): array {
6874 $ qb = $ this ->db ->getQueryBuilder ();
6975
@@ -106,12 +112,23 @@ public function deleteByTokenId(int $tokenId): bool {
106112
107113 public function invalidateOldTokens (int $ token_lifetime = self ::TOKEN_LIFETIME ) {
108114 $ olderThan = $ this ->time ->getTime () - $ token_lifetime ;
109- $ tokensToDelete = $ this ->getOlderThan ($ olderThan );
115+ try {
116+ $ tokensToDelete = $ this ->getOlderThan ($ olderThan );
117+ } catch (Exception $ e ) {
118+ $ this ->logger ->error ('Webhook token deletion failed: ' . $ e ->getMessage (), ['exception ' => $ e ]);
119+ return ;
120+ }
121+
110122
111123 $ this ->logger ->debug ('Invalidating ephemeral webhook tokens older than ' . date ('c ' , $ olderThan ), ['app ' => 'webhook_listeners ' ]);
112124 foreach ($ tokensToDelete as $ token ) {
113- $ this ->tokenMapper ->invalidate ($ this ->tokenMapper ->getTokenById ($ token ->getTokenId ())->getToken ()); // delete token itself
114- $ this ->deleteByTokenId ($ token ->getTokenId ()); // delete db row in webhook_tokens
125+ try {
126+ $ this ->tokenMapper ->invalidate ($ this ->tokenMapper ->getTokenById ($ token ->getTokenId ())->getToken ()); // delete token itself
127+ $ this ->deleteByTokenId ($ token ->getTokenId ()); // delete db row in webhook_tokens
128+ } catch (Exception $ e ) {
129+ $ this ->logger ->error ('Webhook token deletion failed: ' . $ e ->getMessage (), ['exception ' => $ e ]);
130+ }
131+
115132 }
116133 }
117134}
0 commit comments