Stop leaking SQL / $wpdb->last_error in exception messages#37
Merged
Conversation
Database failure exceptions interpolated MySQL error text and assembled queries into their messages, which can surface in REST error payloads or rendered fatals — information disclosure. Messages are now stable; the diagnostic detail is recorded server-side at the point of failure via a shared LogsDatabaseErrors trait (error_log → wp-content/debug.log when WP_DEBUG_LOG is on, the server log otherwise). RecordNotFoundException sites lose the query text but are NOT logged — they are routine control flow (every datastore miss), and logging them would flood operator logs. Invalid-query wrapper exceptions keep their $previous chain, so full detail remains available to structured loggers. Fixes #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stable exception messages; diagnostic detail recorded via error_log at the failure point through a shared
LogsDatabaseErrorstrait. RecordNotFound sites stripped but deliberately not logged (control flow). Updated the test that pinned the old leaking contract to pin the new one (stable message + detail present in the error log). 59 tests green. Fixes #32.