Fixes #7523: defer license-notice translation to avoid _load_textdomain_just_in_time notice - #8655
Open
gunjanjaswal wants to merge 1 commit into
Conversation
rocket_valid_key() can run on plugins_loaded, before the rocket textdomain is loaded on init. Translating the invalid-license notice there triggers the _load_textdomain_just_in_time doing-it-wrong notice on WordPress 6.7+. Store a stable 'invalid_license_data' sentinel in the rocket_check_key_errors transient instead, and expand it to the translated messages in rocket_need_api_key() at render time on admin_notices (after init). Server-returned error strings written during the live license check are still echoed unchanged.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7523
On WordPress 6.7+ with an invalid WP Rocket license,
debug.logfills with_load_textdomain_just_in_time was called incorrectly ... rocket domain ... triggered too earlynotices.Type of change
Detailed scenario
Enter invalid license data (or run with a license that no longer validates) on WP 6.7+. The notice is logged on every admin page load. With this PR it is gone.
Technical description
rocket_valid_key()runs onplugins_loaded(viarocket_init), before therockettextdomain loads oninit, yet it translated the "license data are not valid" message and stored it in therocket_check_key_errorstransient. That string is only rendered later, inrocket_need_api_key()onadmin_notices.This defers the translation to render time, following the pattern from #7103:
rocket_valid_key()now stores a stableinvalid_license_datasentinel, androcket_need_api_key()expands it to the translated sentences when the notice is displayed. Server-returned error strings, written during the live license check inrocket_check_key()(which runs afterinit), are still echoed as-is.Unit tests added for both sides: that the sentinel is stored without any eager translation, and that the renderer expands it while passing plain strings through unchanged.