WordPress / health-check

Health Check is a WordPress plugin that will perform a number of checks on your WordPress install to detect common configuration errors and known issues.
GNU General Public License v2.0
175 stars 56 forks source link

Function _load_textdomain_just_in_time was called incorrectly #477

Open threadi opened 1 week ago

threadi commented 1 week ago

Using the plugin with WordPress 6.7 results with enable debug-mode in this message:

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the health-check domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see [Debugging in WordPress](https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/) for more information. (This message was added in version 6.7.0.) in /var/www/clients/client1/web3/web/wp-includes/functions.php on line 6114

See: https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/

Details with the add_filter-Helper from this page:

#0 /var/www/clients/client1/web3/web/wp-includes/class-wp-hook.php(326): {closure}('...')
#1 /var/www/clients/client1/web3/web/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#2 /var/www/clients/client1/web3/web/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 /var/www/clients/client1/web3/web/wp-includes/functions.php(6003): do_action('...', '...', '...', '...')
#4 /var/www/clients/client1/web3/web/wp-includes/l10n.php(1355): _doing_it_wrong('...', '...', '...')
#5 /var/www/clients/client1/web3/web/wp-includes/l10n.php(1385): _load_textdomain_just_in_time('...')
#6 /var/www/clients/client1/web3/web/wp-includes/l10n.php(194): get_translations_for_domain('...')
#7 /var/www/clients/client1/web3/web/wp-includes/l10n.php(306): translate('...', '...')
#8 /var/www/clients/client1/web3/web/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-files-integrity.php(20): __('...', '...')
#9 /var/www/clients/client1/web3/web/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-files-integrity.php(297): Health_Check_Files_Integrity->__construct()
#10 /var/www/clients/client1/web3/web/wp-content/plugins/health-check/health-check.php(72): require_once('...')
#11 /var/www/clients/client1/web3/web/wp-includes/class-wp-hook.php(324): HealthCheck\{closure}('')
#12 /var/www/clients/client1/web3/web/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#13 /var/www/clients/client1/web3/web/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#14 /var/www/clients/client1/web3/web/wp-settings.php(559): do_action('...')
#15 /var/www/clients/client1/web3/web/wp-config.php(109): require_once('...')
#16 /var/www/clients/client1/web3/web/wp-load.php(50): require_once('...')
#17 /var/www/clients/client1/web3/web/wp-admin/admin.php(34): require_once('...')
#18 /var/www/clients/client1/web3/web/wp-admin/plugins.php(10): require_once('...')

Reason should be the loading of translatable text here: https://github.com/WordPress/health-check/blob/trunk/HealthCheck/Tools/class-health-check-files-integrity.php#L20 but also in multiple other files without any surrounding hook.

lightningspirit commented 17 hours ago

Meanwhile, I created a simple mu-plugin to remove all these notice messages. Turns out, there are many other plugins with the same issue.

Just drop-in in your wp-content/mu-plugins directory.