Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent recursion with log events #39366

Closed
wants to merge 1 commit into from
Closed

Conversation

icewind1991
Copy link
Member

Prevent the event handling of a log event from creating more log events and causing infinite recursion.

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Jul 13, 2023
@icewind1991 icewind1991 added this to the Nextcloud 28 milestone Jul 13, 2023
@icewind1991 icewind1991 requested review from a team, ArtificialOwl, Fenn-CS and come-nc and removed request for a team July 13, 2023 13:21
try {
$this->eventDispatcher->dispatchTyped(new BeforeMessageLoggedEvent($app, $level, $entry));
} catch (Throwable $e) {
// ignore exceptions from inside the logger, as trying to log them would lead to recursion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that means a syntax error in BeforeMessageLoggedEvent class would go unnoticed, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, but that seems better than breaking any logging from such an error.

(also static analysis would detect that specific error)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the inLogEvent boolean is already avoiding recursion on this call, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but an exception in the logging would still cause issues. We have similar logic in other logging places iirc

@icewind1991 icewind1991 requested a review from come-nc July 27, 2023 16:13
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
This was referenced Mar 12, 2024
@skjnldsv
Copy link
Member

Conflicts

@skjnldsv skjnldsv added 2. developing Work in progress technical debt and removed 3. to review Waiting for reviews labels Mar 15, 2024
This was referenced Mar 18, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv closed this Aug 14, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants