wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
701 stars 220 forks source link

WordPress 6.7 Compatibility - Translations loading too early #7102

Closed vlaskiz closed 1 week ago

vlaskiz commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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

piotrbak commented 2 weeks ago

@remyperona Any particular steps? 🤔

CC @wp-media/qa-team

vlaskiz commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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

leodassma commented 2 weeks ago

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

mircobabini commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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.

leodassma commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

Related: https://secure.helpscout.net/conversation/2764307572/523591/