Skip to content

feat: uniform rendering of stack trace from failed DB operations #9677

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

Open
wants to merge 3 commits into
base: 4.7
Choose a base branch
from

Conversation

paulbalandan
Copy link
Member

Description
Resurrecting #9364

All DB drivers except SQL Server logs (with 'error' level) a full stack trace of any failed DB executions via the thrown exception. For SQL Server, the log only includes the message produced by sqlsrv_errors(). Moreover, there's inconsistency with regard to Postgre and OCI8 drivers. Since pg_query() and oci8_execute() only throws because of our error handler, the stack trace also includes the error handler (the [internal function] stack).

This PR aims to make consistent the log output of these drivers by using the same trace rendering. This is already achieved by the private Exceptions::renderBacktrace() method for the thrown exceptions, so this PR extracts it to a new function render_backtrace() and uses that to format the trace. Also, trace coming from the error handler are removed.

For more discussion, refer to previous PR. Hope this passes now.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan
Copy link
Member Author

Gemini told me testing $e->getMessage()directly is unreliable as the underlying PHP-C bridge can be different across machines. I'll fix this later.

@paulbalandan paulbalandan marked this pull request as draft August 12, 2025 18:37
@paulbalandan paulbalandan force-pushed the render-backtrace branch 2 times, most recently from ff1bf0e to 7e8492a Compare August 15, 2025 13:16
@paulbalandan paulbalandan marked this pull request as ready for review August 15, 2025 13:38
@paulbalandan paulbalandan added the database Issues or pull requests that affect the database layer label Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.7 database Issues or pull requests that affect the database layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants