WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 4 months ago

Last modified 3 months ago

#47265 closed defect (bug) (fixed)

Uncaught Error: Call to undefined function load_default_textdomain() in /wp-includes/class-wp-fatal-error-handler.php:41

Reported by: daxelrod Owned by: desrosj
Milestone: 5.2.1 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: has-patch servehappy fixed-major
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Noticed this error after updating to WP 5.2 on PHP 7.3. This error may be related to errors thrown in caching plugins, or other drop-ins which execute and error early.

My error was thrown after a fatal error in WP Redis:

Uncaught RedisException: Connection timed out

I Googled to see if anything had been written on this issue and found a completely separate live website presenting the same error (I am not associated with this website): http://masacoat-asahi.com/

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-content/advanced-cache.php:106
Stack trace:
#0 /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-content/advanced-cache.php(184): SiteManagerAdvancedCache->__construct() 
#1 /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-settings.php(95): include('/home/sites/het...') 
#2 /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-config.php(85): require_once('/home/sites/het...') 
#3 /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-load.php(37): require_once('/home/sites/het...') 
#4 /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-blog-header.php(13): require_once('/home/sites/het...') 
#5 /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/index.php(17): require('/home/sites/het...')
#6 {main} thrown in /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-content/advanced-cache.php on line 106

Fatal error: Uncaught Error: Call to undefined function load_default_textdomain() in /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-includes/class-wp-fatal-error-handler.php:41
Stack trace:
#0 [internal function]: WP_Fatal_Error_Handler->handle()
#1 {main} thrown in /home/sites/heteml/users/h/u/b/hubstyle/web/masacoat-asahi.com/wp-includes/class-wp-fatal-error-handler.php on line 41

It appears this code was introduced in #47093 (changeset 45277) to fix an issue with recovery mode emails locale.

Suggest a conditional for if locale is not defined yet.

Attachments (1)

47265.diff (907 bytes) - added by TimothyBlynJacobs 4 months ago.

Download all attachments as: .zip

Change History (10)

This ticket was mentioned in Slack in #core-php by joyously. View the logs.


4 months ago

#2 @TimothyBlynJacobs
4 months ago

  • Keywords has-patch servehappy dev-feedback added
  • Milestone changed from Awaiting Review to 5.2.1
  • Version set to 5.2

I added a patch that checks for load_default_textdomain and bails translating if it isn't available. AFAICT it is too early to try and use wp_load_translations_early to get access to load_default_textdomain since the option APIs aren't available.

When testing, I also noticed that if a fatal error occurs in advanced-cache.php, WP_Error isn't loaded so I added a check to load it when it isn't available.

I tentatively milestoned this for 5.2.1, I think it is a simple enough fix to include.

#3 @SergeyBiryukov
4 months ago

  • Description modified (diff)

#4 @spacedmonkey
4 months ago

  • Keywords commit added; dev-feedback removed

This is pretty edge case. It is a bug in a drop-in, which again is something we don't support handling. However, this patch is pretty simple, so we should go ahead.

#5 @desrosj
4 months ago

  • Owner set to desrosj
  • Status changed from new to reviewing

#6 @desrosj
4 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45311:

Bootstrap/Load: Prevent PHP errors when a drop-in triggers fatal error protection.

When a drop-in (such as advanced-cache.php) contains a PHP error, additional PHP errors are caused when displaying the error protection screen because load_default_textdomain() and WP_Error are not yet available.

Though recovery mode is not supported for mu-plugins and drop-ins, fatal error protection is. This change ensures the error screen is displayed when a fatal error is encountered within a drop-in and not a white screen.

Props TimothyBlynJacobs, spacedmonkey, daxelrod.
Fixes #47265.

#7 @desrosj
4 months ago

  • Keywords fixed-major added; commit removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backport consideration.

#8 @desrosj
4 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 45315:

Bootstrap/Load: Prevent PHP errors when a drop-in triggers fatal error protection.

When a drop-in (such as advanced-cache.php) contains a PHP error, additional PHP errors are caused when displaying the error protection screen because load_default_textdomain() and WP_Error are not yet available.

Though recovery mode is not supported for mu-plugins and drop-ins, fatal error protection is. This change ensures the error screen is displayed when a fatal error is encountered within a drop-in and not a white screen.

Merges [45311] to the 5.2 branch.

Props TimothyBlynJacobs, spacedmonkey, daxelrod.
Fixes #47265.

#9 @spacedmonkey
3 months ago

  • Component changed from Bootstrap/Load to Site Health
Note: See TracTickets for help on using tickets.