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

Fix translation notice during WooPayments plugin initialization #9727

Closed
Aljnk opened this issue Nov 15, 2024 · 9 comments · Fixed by #9940
Closed

Fix translation notice during WooPayments plugin initialization #9727

Aljnk opened this issue Nov 15, 2024 · 9 comments · Fixed by #9940
Assignees
Labels
focus: payments acceptance & processing type: enhancement The issue is a request for an enhancement.

Comments

@Aljnk
Copy link

Aljnk commented Nov 15, 2024

Update: PHP Notices are triggered during plugin initialization. This issue should focus on fixing notice coming from plulgin init flow.

Describe the bug

Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the <code>woocommerce</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 .../wp-includes/functions.php on line 6114

To Reproduce

  • WP 6.7.0.
  • Other language the EN
    wp-config.php -> define('WP_DEBUG',true);define('WP_DEBUG_DISPLAY',true);@ini_set('display_errors',0);define('SCRIPT_DEBUG',true);

Actual behavior

Open any page

Desktop (please complete the following information):

  • OS: W11
  • Browser chrome (last)

Additional context

debug.log

Internal investigation results by @mordeth (paJDYF-fWD):

The second instance arises during the initialization of the WooPayments plugin, where all classes and gateways are initialized. The main source of the notices was identified as the gateway initialization process.

@Aljnk Aljnk added the type: bug The issue is a confirmed bug. label Nov 15, 2024
@vbelolapotkov
Copy link
Collaborator

For the context, stack trace points to Jetpack-sync package, rather than WooPayments src code, and translation domain is from core rather than WooPayments. So probably the problem has to be solved outside WooPayments repo.

@tsetend
Copy link

tsetend commented Nov 25, 2024

Hi @vbelolapotkov,

I have a customer who reported the error:

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woocommerce-payments 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. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/eueu3893/public_html/wp-includes/functions.php on line 6114

This error message specifically says woocommerce-payments does this still fall under WooCommerce core problem? If yes, is this: woocommerce/woocommerce#53006 the related issue? Can you please help confirm as I want to ensure I'm not looking at the wrong issue?

Thanks!

@vbelolapotkov
Copy link
Collaborator

This is the main issue in Core: woocommerce/woocommerce#52646
I'm yet to figure out if there is anything we could do in the plugin in order to avoid causing early translations before init.

For the context, here is the link to the source of changes in WP and the context behind it: https://core.trac.wordpress.org/ticket/44937

@vbelolapotkov vbelolapotkov added needs triage Manually put issue into triage process. and removed type: bug The issue is a confirmed bug. labels Dec 2, 2024
@vbelolapotkov vbelolapotkov changed the title Notice: Function _load_textdomain_just_in_time was called incorrectly Fix translation notice during WooPayments plugin initialization Dec 4, 2024
@vbelolapotkov vbelolapotkov added focus: payments acceptance & processing type: enhancement The issue is a request for an enhancement. and removed needs triage Manually put issue into triage process. labels Dec 4, 2024
@vbelolapotkov
Copy link
Collaborator

I'm cutting this issue into two based on the investigation results. Updated this issue description and title to narrow down its focus.
Since this issue comes from "breaking" changes in WP 6.7, I'd treat it as a compatibility enhancement rather than a bug.

@deepakpathania sending this part to your team for further prioritization and fixing. Note, some collaboration with core team might be necessary for figuring out the best way forward. See @mordeth's post for more details.

@deepakpathania
Copy link
Contributor

Will #9884 fix this as well? @zinigor

@zinigor
Copy link
Member

zinigor commented Dec 11, 2024

It should, but I don't know if we have any other notices generated by the plugin during its use. The linked PR fixes the use case where the plugin loads i18n strings for Jetpack Connection.

@vbelolapotkov
Copy link
Collaborator

@deepakpathania I doubt it will. The error is the same, but it comes from multiple places as described in @mordeth's post. This issue is focused on fixing notice coming from payment gateway registration during WooPayments init.

@mordeth
Copy link
Contributor

mordeth commented Dec 11, 2024

I confirm Vasily’s statement. PR #9884 would address only the error triggered by Jetpack.

@Aljnk Aljnk closed this as completed Dec 11, 2024
@vbelolapotkov
Copy link
Collaborator

I don't think this issue was fixed, so reopening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: payments acceptance & processing type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants