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

Fixes #7102 Warning related to translations in WordPress 6.7 #7103

Closed remyperona closed 1 week ago

remyperona commented 2 weeks ago

Description

Fixes #7102

A change in WordPress 6.7 is warning when translations functions are used too early. This PR fixes the doing it wrong warnings in the plugin.

Type of change

Detailed scenario

With WordPress 6.7 and WP Rocket 3.17.2, using query monitor to see it easily.

There should be doing it wrong warnings when loading pages in the admin. (also available in debug log)

With this PR, no doing it wrong warnings should happen.

Technical description

Documentation

This change delays the usage of translations functions to later, and also update the hook used to load the plugin textdomain, from plugins_loaded to init.

Mandatory Checklist

Code validation

Code style

codacy-production[bot] commented 2 weeks ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for e5bca6673a3669827f3998edebc0c785210fe561[^1] :white_check_mark: 60.87% (target: 50.00%)
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (e5bca6673a3669827f3998edebc0c785210fe561) | Report Missing | Report Missing | Report Missing | | | Head commit (b7b569e27ce6a1ffa9942ff1376a79acf4311158) | 38172 | 16717 | 43.79% | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#7103) | 23 | 14 | **60.87%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more [^1]: Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Mai-Saad commented 2 weeks ago

Reproducible steps: 1- WP 6.7 2- Query monitor is installed 3- install and activate wpr 3.17.2.1 => notice query monitor displays 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.) in debug.log [14-Nov-2024 14:14:12 UTC] PHP Notice: Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>rocket</code> 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 <code>init</code> action or later. Please see <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0.) in /var/www/new.rocketlabsqa.ovh/htdocs/wp-includes/functions.php on line 6114

Mai-Saad commented 2 weeks ago

@remyperona Thanks for the PR.

Mai-Saad commented 2 weeks ago

@remyperona Thanks for the update, the dynamic lists text is displayed correctly now. Notes:

/cc @piotrbak if nothing is needed for those notes then we can merge the PR. testrail-report-661.pdf

piotrbak commented 2 weeks ago

@remyperona Is the problem with lack of FR translation fixed? Or it's not fixable for now?

remyperona commented 2 weeks ago

yes it's all good now

Mai-Saad commented 1 week ago

@remyperona Thanks for the update. Now translations of the dynamic list update text are there only if script_debug is true, o.w translations won't be reflected.

codacy-production[bot] commented 1 week ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for e5bca6673a3669827f3998edebc0c785210fe561[^1] :white_check_mark: 60.87% (target: 50.00%)
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (e5bca6673a3669827f3998edebc0c785210fe561) | Report Missing | Report Missing | Report Missing | | | Head commit (8211ea29b88eafcbcd749cc132dba2e83724d2c0) | 38172 | 16717 | 43.79% | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#7103) | 23 | 14 | **60.87%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more [^1]: Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.