Skip to content

Commit

Permalink
esc_html in trigger_error causes an exception loop
Browse files Browse the repository at this point in the history
  • Loading branch information
pwtyler committed May 12, 2023
1 parent 4ca8bf6 commit 4b630f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,9 @@ protected function _exception_handler( $exception ) {
try {
$this->last_triggered_error = 'WP Redis: ' . $exception->getMessage();
// Be friendly to developers debugging production servers by triggering an error.
trigger_error( esc_html( $this->last_triggered_error ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error

// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error,WordPress.Security.EscapeOutput.OutputNotEscaped
trigger_error( $this->last_triggered_error, E_USER_WARNING );
} catch ( PHPUnit_Framework_Error_Warning $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// PHPUnit throws an Exception when `trigger_error()` is called. To ensure our tests (which expect Exceptions to be caught) continue to run, we catch the PHPUnit exception and inspect the RedisException message.
}
Expand Down

0 comments on commit 4b630f7

Please sign in to comment.