Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix _load_textdomain_just_in_time warning #4151

Merged
merged 3 commits into from
Mar 27, 2025
Merged

Conversation

malithsen
Copy link
Contributor

Fixes #4085, #4140

Changes proposed in this Pull Request:

This PR fixes a warning that occurs when translations are loaded too early in the WordPress lifecycle. The warning appears as:

Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woocommerce-gateway-stripe domain was triggered too early.

The issue was introduced when the Status page updates were added in #3878, which instantiates the payment gateway during plugins_loaded. This caused translations to be loaded before WordPress's text domain infrastructure was fully initialized.
Initially, I considered moving the entire plugin initialization from plugins_loaded to init. While that fixed the error and should avoid any future instances that could lead to similar errors, it would have been too broad of a change with potential side effects.
Instead, this PR proposes a more targeted fix of only initializing the status page updates during init.

This ensures:

  • Translations are loaded at the correct time (priority 10)
  • Status page is initialized after translations (priority 15)
  • Only the Status page functionality is affected,

Testing instructions

To reproduce the error:

  1. Switch to develop.
  2. Enable debugging by adding define( 'WP_DEBUG', true ); to your wp-config.php
  3. Change site language to English (UK) via Settings -> General -> Site Language.
  4. Go to Dashboards -> Updates. Click on "Re-install version 6.7.2–en_GB"
  5. Notice the warning on top of the page.

Test the fix:

  1. Switch to this branch.
  2. Above notice should no longer be visible.

Test for regressions:

Follow the instructions in #3878


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@malithsen malithsen requested review from a team and Mayisha and removed request for a team March 26, 2025 19:40
@malithsen malithsen marked this pull request as ready for review March 26, 2025 19:40
Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the steps to reproduce but could not reproduce the error in develop 🤷
But the changes look reasonable and it should fix the issue. Approving, :shipit:

@malithsen malithsen enabled auto-merge (squash) March 27, 2025 13:48
@malithsen malithsen merged commit b9e8937 into develop Mar 27, 2025
35 of 36 checks passed
@malithsen malithsen deleted the fix/translation-warning branch March 27, 2025 14:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debug error with calling _load_textdomain_just_in_time too early
2 participants