Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_load_textdomain_just_in_time was called incorrectly #919

Open
f14m07 opened this issue Nov 18, 2024 · 10 comments · May be fixed by #940
Open

_load_textdomain_just_in_time was called incorrectly #919

f14m07 opened this issue Nov 18, 2024 · 10 comments · May be fixed by #940

Comments

@f14m07
Copy link

f14m07 commented Nov 18, 2024

Hi,
I have this message in my php error log since the last WP 6.7 update.
To see this error your site must be in a foreign language and you must have debug mode.

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the query-monitor 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 for more information. (This message was added in version 6.7.0.) in /Users/xxxx/Local Sites/clone-reve/app/public/wp-includes/functions.php on line 6114

This isn't the only plugin to have this problem.
You must be in debug mode and with a foreign lang site to reproduce this notice.
Could you update your code please ?

Thanks for all.

Have a nice day.

Frédéric

@johnbillion
Copy link
Owner

johnbillion commented Nov 18, 2024

Thanks for the report. I've already been looking into a fix for this. It's ironically caused by the "Doing it wrong" handler in Query Monitor which gets triggered when another plugin loads a translation too early.

@johnbillion johnbillion added this to the 3.17.0 milestone Nov 18, 2024
@f14m07
Copy link
Author

f14m07 commented Nov 18, 2024

It's true because having deactivated the other plugins that have the same error, I no longer get the query monitor error. Thanks for your quick response

@johnbillion
Copy link
Owner

@f14m07 Are you still seeing this problem with WordPress 6.7.1?

@johnbillion johnbillion removed this from the 3.17.0 milestone Nov 27, 2024
@f14m07
Copy link
Author

f14m07 commented Nov 27, 2024

No it's Ok Not new issue.

@cbratschi
Copy link

Still getting this error in WordPress 6.7.1:

[06-Dec-2024 16:46:04 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the query-monitor 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 for more information. (This message was added in version 6.7.0.) in /home/site/wp-includes/functions.php on line 6114

@felipeelia
Copy link
Contributor

felipeelia commented Dec 6, 2024

I'm seeing this problem in a different context now. ElasticPress makes a remote HTTP call using wp_remote_post() and as Query Monitor monitors all those, QM itself is calling __() earlier than expected here. I'm still debugging it but wanted to share this finding asap, so hopefully it helps. Also worth noting I'm having a hard time reproducing all these problems, as the notice will not be displayed unless I delete all transients using wp transient delete --all.

@johnbillion
Copy link
Owner

Thanks. This seems like a never ending problem once you dig into it.

I'll need to do some work to shift all the translation strings out of the collectors and into the output.

@johnbillion johnbillion changed the title _load_textdomain_just_in_time was called <strong>incorrectly</strong> _load_textdomain_just_in_time was called incorrectly Dec 18, 2024
@afragen
Copy link

afragen commented Dec 19, 2024

Just documenting a conversation with John. I was seeing similar errors and think it may be do to a response from wp_remote_get() returning something that QM is trying to translate from doing_it_wrong. I believe the following lines from my log are the inciting translations from QM.

[18-Dec-2024 20:04:58 UTC] PHP  17. __($text = 'Plugin: %s', $domain = 'query-monitor') /Users/afragen/Local_Sites/lightning/app/public/wp-content/plugins/query-monitor/classes/Util.php:200
[18-Dec-2024 20:04:58 UTC] PHP  18. translate($text = 'Plugin: %s', $domain = 'query-monitor') /

[18-Dec-2024 20:04:58 UTC] PHP  37. __($text = 'WordPress Core', $domain = 'query-monitor') /Users/afragen/Local_Sites/lightning/app/public/wp-content/plugins/query-monitor/classes/Util.php:246
[18-Dec-2024 20:04:58 UTC] PHP  38. translate($text = 'WordPress Core', $domain = 'query-monitor') /

What a PITA this change has been. Silently failing seems to be so much better.

@afragen
Copy link

afragen commented Dec 20, 2024

Got tired of seeing this and with some help from John (thanks John) I give you.

https://gist.github.com/afragen/986ba6046ebea963074283a77cae07fc

@kagg-design kagg-design linked a pull request Dec 22, 2024 that will close this issue
@kagg-design
Copy link

It can be temporarily fixed by #940.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants