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

WordPress 6.7 Compatibility - Translations loading too early #7102

Closed
vlaskiz opened this issue Nov 13, 2024 · 19 comments · Fixed by #7103
Closed

WordPress 6.7 Compatibility - Translations loading too early #7102

vlaskiz opened this issue Nov 13, 2024 · 19 comments · Fixed by #7103
Assignees
Labels
community Issues created by someone outside of our team priority: medium Issues which are important, but no one will go out of business. severity: minor Defect that does not affect functionality
Milestone

Comments

@vlaskiz
Copy link

vlaskiz commented Nov 13, 2024

Describe the bug

"Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the rocket 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. (This message was added in version 6.7.0.)"

As per the notice on WP 6.7.0, translations are being loaded too early and should be moved to another (init or later) hook.

@piotrbak piotrbak added community Issues created by someone outside of our team priority: medium Issues which are important, but no one will go out of business. severity: minor Defect that does not affect functionality labels Nov 13, 2024
@piotrbak piotrbak added this to the 3.17.3 milestone Nov 13, 2024
@piotrbak
Copy link
Contributor

Hello @vlaskiz thanks for creating the issue.

We've been trying to replicate the issue but we were not able to. Could you provide us steps or environment that's needed in order to move forward?

If you're not sure about that, it'd be great if you could share with us access to your website.

@remyperona
Copy link
Contributor

@piotrbak I'm able to reproduce the issue with WP 6.7 locally

@piotrbak
Copy link
Contributor

@remyperona Any particular steps? 🤔

CC @wp-media/qa-team

@vlaskiz
Copy link
Author

vlaskiz commented Nov 13, 2024

Hello,

It's a PHP notice, so you would need to check if you can see those. Can be easily detected with Query Monitor.

But you are right, looking at it, on some websites it generates the notice among a few other plugins, and on some it does not (with same other plugins present, that do not generate the notice either).

Either way, you are hooking translations into plugins_loaded hook, while the notice recommends 'init' or later.

@remyperona
Copy link
Contributor

I looked into what was triggering the warning, there is 3 files to update to prevent it. And we should also update the hook on which we load the translations like said above.

I can create a quick PR for this change

@piotrbak
Copy link
Contributor

Yes, let's do it since it'll be flooding the support team. We'll need to have a way to reproduce it for the QA team tests though.

@mircobabini
Copy link

In core, the check is against after_setup_theme action already run or not.

@leodassma
Copy link

leodassma commented Nov 14, 2024

how to solve this problem ?? if anyone tell me how to solved .

@mircobabini
Copy link

Wait for a release. In the meanwhile, be sure to have WP_DEBUG_LOG = false or use a filter to temporarily suppress doing-it-wrong notices.

add_filter( 'doing_it_wrong_trigger_error', '__return_false' );

Temporary but effective.

@mmariom
Copy link

mmariom commented Nov 14, 2024

define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', false);

Then don't forget to restart your server and purge the cache if you use some!

@vijetaR
Copy link

vijetaR commented Nov 14, 2024

Could someone please help with a test case to check locally, or provide any helpful steps? I did check using Query Monitor, but no notices were shown.

@Mai-Saad Mai-Saad self-assigned this Nov 14, 2024
@leodassma
Copy link

Could someone please help with a test case to check locally, or provide any helpful steps? I did check using Query Monitor, but no notices were shown.

add_filter( 'doing_it_wrong_trigger_error', '__return_false' ); use this bro .

@leodassma
Copy link

Wait for a release. In the meanwhile, be sure to have WP_DEBUG_LOG = false or use a filter to temporarily suppress doing-it-wrong notices.

add_filter( 'doing_it_wrong_trigger_error', '__return_false' );

Temporary but effective.

thank you so much bro...👍 It works ...

@joejoe04
Copy link

@supertrooper2
Copy link

I am unsure into which file the following code should be inserted:

add_filter( 'doing_it_wrong_trigger_error', '__return_false' );

Should it ne inserted into the functions.php file?

Please advise.

@mircobabini
Copy link

mircobabini commented Dec 25, 2024

@supertrooper2 Create the mu-plugins folder into wp-content if it does not exist. Then create a disable-doing-it-wrong-notice.php into it and paste this.

<?php
/**
 * Plugin Name: Disable Doing It Wrong Notice (Load Textdomain)
 * Description: Disables the "Doing it wrong" notice that appears when a textdomain is loaded just in time.
 */
add_filter( 'doing_it_wrong_trigger_error', function ( $doing_it_wrong, $function_name ) {
	if ( '_load_textdomain_just_in_time' === $function_name ) {
		return false;
	}

	return $doing_it_wrong;
}, 10, 2 );

@supertrooper2
Copy link

supertrooper2 commented Dec 25, 2024 via email

@supertrooper2
Copy link

Hi Mirco, I managed to create the disable-doing-it-wrong-notice.php file and it works perfectly.

Many thanks for the great support.

@Wesley-Carnicle
Copy link

I added the file and haven't seen it do anything yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issues created by someone outside of our team priority: medium Issues which are important, but no one will go out of business. severity: minor Defect that does not affect functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.