Skip to content

Commit

Permalink
Fixed loading textdomain in show_error_and_die() (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukhnenko committed Mar 12, 2024
1 parent 5cd5c0c commit b582fba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Reverted behavioral change to `sanitize_key_part()`
- Actually fix rare fatal error in `show_error_and_die()`

## 2.5.1

Expand Down
16 changes: 9 additions & 7 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2899,15 +2899,17 @@ protected function handle_exception( $exception ) {
* @return void
*/
protected function show_error_and_die( Exception $exception ) {
if ( ! function_exists( 'get_template_directory' ) ) {
require_once ABSPATH . WPINC . '/theme.php';
}

wp_load_translations_early();

add_filter( 'pre_determine_locale', function () {
return defined( 'WPLANG' ) ? WPLANG : 'en_US';
} );
$domain = 'redis-cache';
$locale = defined( 'WPLANG' ) ? WPLANG : 'en_US';
$mofile = WP_LANG_DIR . "/plugins/{$domain}-{$locale}.mo";

if ( load_textdomain( $domain, $mofile, $locale ) === false ) {
add_filter( 'pre_determine_locale', function () {
return defined( 'WPLANG' ) ? WPLANG : 'en_US';
} );
}

// Load custom Redis error template, if present.
if ( file_exists( WP_CONTENT_DIR . '/redis-error.php' ) ) {
Expand Down

0 comments on commit b582fba

Please sign in to comment.