WordPress / wp20.wordpress.net

Celebrating 20 years of WordPress
5 stars 1 forks source link

Fatal with Japanese locale #94

Closed adamwoodnz closed 1 year ago

adamwoodnz commented 1 year ago

The site is crashing when the Japanese locale is selected, but only occurs if the locale notice is rendered.

The error is triggered by this printf

https://github.com/WordPress/wp20.wordpress.net/blob/b7776b71f675ce9698eb85de1b39c207d24bcffc/wp-content/mu-plugins/locales.php#L243-L244

Screenshots

Local

Screen Shot 2023-05-04 at 1 28 38 PM

Prod

Screen Shot 2023-05-04 at 8 12 26 AM

Stack trace:

PHP Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given in /srv/htdocs/wp-content/mu-plugins/locales.php:244 Stack trace: #0 /srv/htdocs/wp-content/mu-plugins/locales.php(244): printf('\xE3\x81\x93\xE3\x81\xAE\xE8\xA8\x80\xE8\xAA\x9E\xE3\x81\xAE...', 'https://transla...') #1 /srv/htdocs/wp-content/themes/twentyseventeen-wp20/header.php(37): WP20\Locales\locale_notice() #2 /wordpress/core/6.2/wp-includes/template.php(783): require_once('/srv/htdocs/wp-...') #3 /wordpress/core/6.2/wp-includes/template.php(718): load_template('/srv/htdocs/wp-...', true, Array) #4 /wordpress/core/6.2/wp-includes/general-template.php(48): locate_template(Array, true, true, Array) #5 /srv/htdocs/wp-content/themes/twentyseventeen-wp20/page-whats-on.php(1): get_header() #6 /wordpress/core/6.2/wp-includes/template-loader.php(106): include('/srv/htdocs/wp-...') #7 /wordpress/core/6.2/wp-blog-header.php(19): require_once('/wordpress/core...') #8 /wordpress/core/6.2/index.php(17): require('/wordpress/core...') #9 {main} thrown in /srv/htdocs/wp-content/mu-plugins/locales.php on line 244
adamwoodnz commented 1 year ago

The Japanese translation for this string includes a % sign, which could be the cause:

Screen Shot 2023-05-04 at 1 58 51 PM

nukaga commented 1 year ago

Thank you very much! We solved the problem by changing the % sign in the translation to a multibyte .

adamwoodnz commented 1 year ago

Another way to fix it: when sprintf() or printf() is used, any occurrences of the usual "%" character must be escaped as "%%".