Closed OllieJones closed 1 year ago
You need to call wp_load_translations_early
. See the following example from core.
:+1:
All set.
I am not seeing a different error here.
| <br />
-- | --
| <b>Fatal error</b>: Uncaught Error: Call to a member function get() on null in /var/www/src/wp-content/object-cache.php:2155
| Stack trace:
| #0 /var/www/src/wp-includes/option.php(165): wp_cache_get('notoptions', 'options')
| #1 /var/www/src/wp-includes/l10n.php(63): get_option('WPLANG')
| #2 /var/www/src/wp-includes/l10n.php(139): get_locale()
| #3 /var/www/src/wp-includes/l10n.php(1274): determine_locale()
| #4 /var/www/src/wp-includes/l10n.php(1305): _load_textdomain_just_in_time('sqlite-object-c...')
| #5 /var/www/src/wp-includes/l10n.php(187): get_translations_for_domain('sqlite-object-c...')
| #6 /var/www/src/wp-includes/l10n.php(299): translate('The SQLite Obje...', 'sqlite-object-c...')
| #7 /var/www/src/wp-content/object-cache.php(726): __('The SQLite Obje...', 'sqlite-object-c...')
| #8 /var/www/src/wp-content/object-cache.php(2012): WP_Object_Cache::has_sqlite()
| #9 /var/www/src/wp-includes/load.php(730): wp_cache_init()
| #10 /var/www/src/wp-settings.php(131): wp_start_object_cache()
| #11 /var/www/wp-config.php(109): require_once('/var/www/src/wp...')
| #12 /var/www/src/wp-load.php(55): require_once('/var/www/wp-con...')
| #13 /var/www/src/wp-blog-header.php(13): require_once('/var/www/src/wp...')
| #14 /var/www/src/_index.php(17): require('/var/www/src/wp...')
| #15 /var/www/src/index.php(19): require_once('/var/www/src/_i...')
| #16 {main}
| thrown in <b>/var/www/src/wp-content/object-cache.php</b> on line <b>2155</b><br />
The fix is simple.
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
global $wp_object_cache;
if( ! $wp_object_cache ){
return false;
}
return $wp_object_cache->get( $key, $group, $force, $found );
}
We need to do the same for wp_cache_get
, wp_cache_set
and wp_cache_add
.
CC @OllieJones
Under some circumstances, the drop-in needs to use i18n functions before the rest of WordPress is loaded. Props to @carstenbach.