Skip to content

Commit 046b434

Browse files
committed
[CMSP-390] esc_html in trigger_error causes an exception loop (#421)
1 parent 59aaee4 commit 046b434

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a
105105
## Changelog ##
106106

107107
### Latest ###
108+
* Bug fix: Removes exception loop caused by `esc_html` in `_exception_handler()` [[421](https://github.com/pantheon-systems/wp-redis/pull/421)]
108109

109110
### 1.4.1 (May 11, 2023) ###
110111
* Bug fix: `wp_cache_flush_runtime` should only clear the local cache [[413](https://github.com/pantheon-systems/wp-redis/pull/413)]

object-cache.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,9 @@ protected function _exception_handler( $exception ) {
14701470
try {
14711471
$this->last_triggered_error = 'WP Redis: ' . $exception->getMessage();
14721472
// Be friendly to developers debugging production servers by triggering an error.
1473-
trigger_error( esc_html( $this->last_triggered_error ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
1473+
1474+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error,WordPress.Security.EscapeOutput.OutputNotEscaped
1475+
trigger_error( $this->last_triggered_error, E_USER_WARNING );
14741476
} catch ( PHPUnit_Framework_Error_Warning $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
14751477
// 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.
14761478
}

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a
103103
== Changelog ==
104104

105105
= Latest =
106+
* Bug fix: Removes exception loop caused by `esc_html` in `_exception_handler()` [[421](https://github.com/pantheon-systems/wp-redis/pull/421)]
106107

107108
= 1.4.1 (May 11, 2023) =
108109
* Bug fix: `wp_cache_flush_runtime` should only clear the local cache [[413](https://github.com/pantheon-systems/wp-redis/pull/413)]

0 commit comments

Comments
 (0)