Skip to content

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
@paulbalandan paulbalandan merged commit 1326621 into codeigniter4:4.7 Aug 18, 2025
50 checks passed
@paulbalandan paulbalandan deleted the render-backtrace branch August 18, 2025 13:43
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

2 participants