#57051 closed defect (bug) (fixed)
Fatal error when loading translations early due to a DB error with WPLANG set
Reported by: | azurseisme | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 6.1.1 | Priority: | normal |
Severity: | normal | Version: | 6.1 |
Component: | I18N | Keywords: | has-patch commit fixed-major |
Focuses: | Cc: |
Description (last modified by )
Since a few days (I think after upgrading to WP 6.1) , I have the following bug
PHP Fatal error: Uncaught Error: Call to undefined function wp_cache_get() in /wp-includes/option.php:165 Stack trace: #0 /wp-includes/l10n.php(63): get_option() #1 /wp-includes/l10n.php(139): get_locale() #2 /wp-includes/l10n.php(766): determine_locale() #3 /wp-includes/load.php(1395): load_textdomain() #4 /wp-includes/class-wpdb.php(1198): wp_load_translations_early() #5 /wp-includes/class-wpdb.php(1858): wpdb->select() #6 /wp-includes/class-wpdb.php(734): wpdb->db_connect() #7 /wp-includes/load.php(562): wpdb->__construct() #8 /wp-settings.php(124): require_wp_db() #9 /wp-config.php(89): require_once('/home/Web/Azurs...') #10 /wp-load.php(50): require_once(' in /wp-includes/option.php on line 165, referer: https://subdomain.domain.com/post-name PHP Fatal error: Uncaught Error: Call to a member function set() on null in /wp-includes/l10n.php:784 Stack trace: #0 /wp-includes/l10n.php(872): load_textdomain() #1 /wp-includes/class-wp-fatal-error-handler.php(47): load_default_textdomain() #2 [internal function]: WP_Fatal_Error_Handler->handle()\n#3 {main} thrown in /wp-includes/l10n.php on line 784, referer: https://subdomain.domain.com/post-name
I have applied the patch described by #56952 but no success
The site is down, except for pages in the cache but I cannot access the admin page
Change History (18)
#1
@
23 months ago
- Component changed from Users to I18N
- Milestone changed from Awaiting Review to 6.1.1
- Severity changed from major to normal
#2
@
23 months ago
I am self hosting the site, and I have no troubles with the database, no warning messages.
I have restored a database dated 15 october and I have the same issue.
It is very strange since I have a dozen of wordpress sites and the other sites are all OK
#3
@
23 months ago
I don't think it's an issue with the content of your database @azurseisme, but when WordPress tries to select the database you've specified in your wp-config.php
file, it is failing to do so.
#6
@
23 months ago
- Resolution set to invalid
- Status changed from new to closed
That was the problem, I am confused.
I close the bug
Thanks a lot
#7
@
23 months ago
- Resolution invalid deleted
- Status changed from closed to reopened
- Summary changed from Call to undefined function wp_cache_get() wp-includes/option.php:165 to Fatal error when loading translations early due to a DB error with WPLANG set
I'm glad you got it working @azurseisme!
I'm going to reopen this ticket, though, because WordPress should be showing you a pretty error message instead of fatal erroring in this case.
To replicate, change your DB_NAME
to an invalid database, and ensure either WPLANG
or $wp_locale_package
is defined.
#8
@
23 months ago
I think the first error will be fixed by #57060. The second one shouldn't be triggered then either but I guess we should still add some sanity check in load_textdomain()
whether the $wp_textdomain_registry
global is set?
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
23 months ago
This ticket was mentioned in PR #3603 on WordPress/wordpress-develop by @ocean90.
23 months ago
#10
- Keywords has-patch added
Ensures that the global $wp_textdomain_registry
is set up which is used by the load_*_textdomain()
functions.
For testing change your DB_NAME
to an invalid database and add define( 'WPLANG', 'de_DE' );
to your wp-config.php
.
Errors before:
Fatal error: Uncaught Error: Call to a member function set() on null in /var/www/src/wp-includes/l10n.php:784 Stack trace: #0 /var/www/src/wp-includes/load.php(1401): load_textdomain('default', '/var/www/src/wp...', 'de_DE') #1 /var/www/src/wp-includes/class-wpdb.php(1198): wp_load_translations_early() #2 /var/www/src/wp-includes/class-wpdb.php(1858): wpdb->select('wordpress_devel...', Object(mysqli)) #3 /var/www/src/wp-includes/class-wpdb.php(734): wpdb->db_connect() #4 /var/www/src/wp-content/plugins/query-monitor/classes/QM_DB.php(36): wpdb->__construct('root', 'password', 'wordpress_devel...', 'mysql') #5 /var/www/src/wp-content/plugins/query-monitor/wp-content/db.php(74): QM_DB->__construct('root', 'password', 'wordpress_devel...', 'mysql') #6 /var/www/src/wp-includes/load.php(550): require_once('/var/www/src/wp...') #7 /var/www/src/wp-settings.php(124): require_wp_db() #8 /var/www/wp-config.php(82): require_once('/var/www/src/wp...') #9 /var/www/src/wp-load.php(55): require_once('/var/www/wp-con...') #10 /var/www/sr in /var/www/src/wp-includes/l10n.php on line 784 Fatal error: Uncaught Error: Call to undefined function wp_cache_get() in /var/www/src/wp-includes/option.php:165 Stack trace: #0 /var/www/src/wp-includes/l10n.php(63): get_option('WPLANG') #1 /var/www/src/wp-includes/l10n.php(139): get_locale() #2 /var/www/src/wp-includes/l10n.php(866): determine_locale() #3 /var/www/src/wp-includes/class-wp-fatal-error-handler.php(47): load_default_textdomain() #4 [internal function]: WP_Fatal_Error_Handler->handle() #5 {main} thrown in /var/www/src/wp-includes/option.php on line 165
Trac ticket: https://core.trac.wordpress.org/ticket/57051
#11
@
23 months ago
With [54798] and https://github.com/WordPress/wordpress-develop/pull/3603 this should be fixed. @azurseisme Are you able to test these patches?
@peterwilsoncc commented on PR #3603:
23 months ago
#12
Is it possible to add tests for this?
I suspect not because wp_load_translations_early()
is untested but I live in hope.
#13
@
23 months ago
- Keywords commit added
The linked pull request has approvals from three committers, marking as commit ready.
#14
@
23 months ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from reopened to closed
In 54803:
It looks like
wp_load_translations_early
now has a side-effect of requiring the Object Cache to be loaded. My first thought is this might be related to some of the translation performance improvements @swissspidy and @ocean90 worked on in #39210.That being said @azurseisme, the root issue is that it looks like your site is having trouble connecting to your MySQL database which is why WordPress is trying to present this error in the first place. For help with that, I'd recommend reaching out to your hosting company.