Skip to content

Commit

Permalink
call error hook earlier (related #490)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkruss authored Oct 6, 2023
1 parent 152e8bb commit c74d2d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Call `redis_object_cache_error` action before `wp_die()`

## 2.4.4

- Improved handling of unexpected transaction results
Expand Down
19 changes: 10 additions & 9 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2875,21 +2875,22 @@ protected function handle_exception( $exception ) {

error_log( $exception ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log

if ( ! $this->fail_gracefully ) {
$this->show_error_and_die( $exception );
}

$this->errors[] = $exception->getMessage();

if ( function_exists( 'do_action' ) ) {
/**
* Fires on every cache error
* Fires when an object cache related error occurs.
*
* @since 1.5.0
* @param \Exception $exception The exception triggered.
* @param \Exception $exception The exception.
* @param string $message The exception message.
*/
do_action( 'redis_object_cache_error', $exception );
do_action( 'redis_object_cache_error', $exception, $exception->getMessage() );
}

if ( ! $this->fail_gracefully ) {
$this->show_error_and_die( $exception );
}

$this->errors[] = $exception->getMessage();
}

/**
Expand Down

0 comments on commit c74d2d1

Please sign in to comment.