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

Since WP 6.7 load_textdomain or load_textdomain_just_in_time was called incorrectly notices #115

Open
chludwig opened this issue Jan 14, 2025 · 1 comment

Comments

@chludwig
Copy link

Since WordPress v6.7 notices like this are thrown when translations are used to early in the loading sequence.

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the post-smtp 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 /app/public/wp-includes/functions.php on line 6114

So currently it is impossible to update WordPress to a version >6.2.2 when debugging and display errors is enabled (what usually should in all development and test stages).
The changes in the beta v3.0.1 don't solve the problem. For further details see https://wordpress.org/support/topic/translation-loading-for-the-post-smtp-domain-was-triggered-too-early/

@ara303
Copy link

ara303 commented Jan 31, 2025

This makes debugging or any sort of development much harder, without an awkward workaround. For the moment the options are: 1.) disable the plugin when in development (not really viable when developing features that specifically revolve around email, as I am doing at the moment!), 2.) back-dating WordPress v6.6.1 (which is what I'm doing at the moment), or the ultimate option of 3.) just using a different SMTP/email service management plugin entirely.

I can also confirm @chludwig's assertion that v3.0.1 does not fix this. I am running v3.0.2 and still get my debug log file absolutely spammed with WP notices quite specifically blaming post-smtp.

I don't expect a fix overnight, but it would be wonderful to know this is on your radar/roadmap to be fixed at some point, please.

From what I can gather this is quite an easy fix. It just comes down to replacing instances of plugins_loaded when loading translation files with init.

Running grep -r "plugins_loaded" over my post-smtp directory reveals the following instantances:

Postman/Phpmailer/PostsmtpMailer.php:add_action('plugins_loaded', function() {
Postman/Postman-Mail/PostmanMailjetTransport.php:        // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanPostmarkTransport.php:            // add a hook on the plugins_loaded event
Postman/Postman-Mail/libs/vendor/woocommerce/action-scheduler/action-scheduler.php:             add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
Postman/Postman-Mail/libs/vendor/woocommerce/action-scheduler/action-scheduler.php:     add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_7_dot_1', 0, 0 ); // WRCS: DEFINED_VERSION.
Postman/Postman-Mail/libs/vendor/woocommerce/action-scheduler/action-scheduler.php:     if ( did_action( 'plugins_loaded' ) && ! doing_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler', false ) ) {
Postman/Postman-Mail/PostmanSendGridTransport.php:              // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanSendinblueTransport.php:        // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanElasticEmailTransport.php:        // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanMailgunTransport.php:               // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanMandrillTransport.php:              // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanSendpulseTransport.php:                     // add a hook on the plugins_loaded event.
Postman/Postman-Mail/PostmanSparkPostTransport.php:            // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanGmailApiModuleTransport.php:                // add a hook on the plugins_loaded event
Postman/Postman-Mail/PostmanSmtpModuleTransport.php:            // add a hook on the plugins_loaded event
Postman/Mobile/mobile.php:        add_action( 'plugins_loaded', array( $this, 'remove_device' ) );
Postman/Postman.php:            // hook on the plugins_loaded event
Postman/Postman.php:            add_action( 'plugins_loaded', array(
Postman/Postman.php:                            'on_plugins_loaded',
Postman/Postman.php:     * Functions to execute on the plugins_loaded event
Postman/Postman.php:    public function on_plugins_loaded() {
Postman/Postman.php:            // register the setup_admin function on plugins_loaded because we need to call
freemius/includes/class-freemius.php:         * This action is connected to the 'plugins_loaded' hook and helps to determine
freemius/includes/class-freemius.php:         *       1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
freemius/includes/class-freemius.php:         *       2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
freemius/includes/class-freemius.php:         *       3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
freemius/includes/class-freemius.php:        function _plugins_loaded() {
freemius/includes/class-freemius.php:                     * During the plugin activation (not theme), 'plugins_loaded' will be already executed
freemius/includes/class-freemius.php:                     * then triggers 'plugins_loaded', and only then include the code of the plugin that
freemius/includes/class-freemius.php:                     * is activated. Which means that _plugins_loaded() will NOT be executed during the
freemius/includes/class-freemius.php:                         0 == did_action( 'plugins_loaded' )
freemius/includes/class-freemius.php:                        add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
freemius/includes/class-freemius.php:                        $this->_plugins_loaded();
freemius/includes/class-freemius.php:                add_action( 'plugins_loaded', array( &$this, '_run_garbage_collector' ) );
freemius/includes/class-freemius.php:            if ( 0 == did_action( 'plugins_loaded' ) ) {
freemius/includes/class-freemius.php:                add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants