Ludwig C.
Forum Replies Created
-
Hi @aqibkhan9,
Unfortunately there is no cure in the problem itself and I don’t see any relevant changes in the code but moving the function call of load_plugin_textdomain() to an other location in the source code. As described already, this is not the only problem we’re facing in the PostSMTP plugin (at least in the free version of it).
Can I assist you in setting up a test environment? Because I wonder why your developers don’t see the errors on their local development systems. In our environments it isn’t even possible to login in to the WP Admin when WP_DEBUG and WP_DEBUG_DISPLAY is enabled (what should be in a development environment).
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 theinit
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /app/web/wp-includes/functions.php on line 6114Warning: Cannot modify header information – headers already sent by (output started at /app/web/wp-includes/functions.php:6114) in /app/web/wp-includes/pluggable.php on line 1435
Warning: Cannot modify header information – headers already sent by (output started at /app/web/wp-includes/functions.php:6114) in /app/web/wp-includes/pluggable.php on line 1438
In my environment the (first) error is caused by line 207 of file /wp-content/plugins/post-smtp/Postman/Postman-Mail/PostmanGmailApiModuleTransport.php when a translation function gets called
$message = sprintf ( __ ( 'You have configured...
protected function validateTransportConfiguration() {
$messages = parent::validateTransportConfiguration ();
if (empty ( $messages )) {
$this->setReadyForOAuthGrant ();
if ($this->isPermissionNeeded ()) {
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
$message = sprintf ( __ ( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'post-smtp' ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () );
$message .= sprintf ( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl (), $this->getScribe ()->getRequestPermissionLinkText () );
array_push ( $messages, $message );
$this->setNotConfiguredAndReady ();
}
}
return $messages;
}Here is the Stack Trace where I marked the relevant calls bold.
- l10n.php:1370, _load_textdomain_just_in_time()
- l10n.php:1408, get_translations_for_domain()
- l10n.php:194, translate()
- l10n.php:306, __()
- PostmanGmailApiModuleTransport.php:207, PostmanGmailApiModuleTransport->validateTransportConfiguration()
- PostmanModuleTransport.php:111, PostmanAbstractModuleTransport->init()
- PostmanTransportRegistry.php:33, PostmanTransportRegistry->registerTransport()
- Postman.php:469, Postman->registerTransports()
- Postman.php:219, Postman->on_plugins_loaded()
- class-wp-hook.php:324, WP_Hook->apply_filters()
- class-wp-hook.php:348, WP_Hook->do_action()
- plugin.php:517, do_action()
- wp-settings.php:559, require_once()
- wp-config.php:127, require_once()
- wp-load.php:50, require_once()
- admin.php:34, require_once()
- index.php:10, {main}()
Here is my local configuration, sending emails to my local MailHog container by SMTP.
eNp1VMGS2yAM/ZUO502apN1OJ6c9tL/QU2cYAkqiBhADIttsp/9eYTub2E59sXkPPQn05D8KotV8SaC2KlIE9aSOVDia0BCmiItg0AucKLParleb5ydVIDrIGjqqBS4yJH958SASvHRNBuIZPCXQ/eb/beNsYmna1ypK4CR4e+mmD7kImqSogTGVj5OSh3ruqv7w7fsPIajbbD1CZI1OyClYwGbgntiZglZ3bC2QB7kxkUwpr5QHqWCiy+i9Ngn1CS492so5ZHRzFOPOVxjj7ZC/gB+DfXljkVR9gbl2D08D2sUFk0+T/UmgRs2zHmocg+BNYbRdsycq0pDNgR5rOJKvqG+X2PVeM/WrPWULbrq0drTcXddHMK43QidkJBADUJXGfVk9KUsxgmWkeMPXgns6aA/iQ7X9vJKnr043GKLZeWht5FxB3THB/BaWM4Lk2zxLUJbjBHLtHCmTq12mq3dtxiR9wjeh15uvgoakHTbD//wo3+00xvudsSfdmfqWOdKMvBu+GddP4GoKS8drRr7cxuGd32cK71M60xt7fJJrZPNIjHu0prthiTqLHYRxsDfVc3NZLUc6ywg2zcF4V4jpBHEwjG8J7oCRsD1KuaArPsp6PcVrWhgXML6c0byB/EYY+x+JpCqtLVv1ablabtTff1J8riA=
I already gave some hints to fix this issue in my last post. If you need further assistance, feel free to contact us.
Btw. why do you write ‘configurationMessages’ into PostmanModuleTransport when the messages never seem to be used? At least
getConfigurationMessages()
never gets called. Even when running the internal Checks in PostSMTP.@aqibkhan9 Thanks for your reply. I checked the beta 3.0.1 and still face the same problem!
All your developers did was moving the
load_plugin_textdomain()
into an own method and call that during theinit
action hook.It is the
registerTransports()
that is called inon_plugins_loaded()
too early because it’s already using translations for the messages when validating the transport configurations! For example seeplugins/post-smtp/Postman/Postman-Mail/PostmanGmailApiModuleTransport.php
line 207.To solve the problem you could do one of these things:
- Simply call the complete
on_plugins_loaded()
?method later, with theinit
action (as described in my last post). - Rewrite the complete message handling for example by returning an array with the message as an untranslated string plus the variables and do the
sprintf()
and translation stuff inPostmanAbstractModuleTransport->getConfigurationMessages()
that seems to be triggered later. - Leave the transport configuration error messages untranslated (btw. since you changed the loading sequence so that
loadTextDomain()
is triggered after theon_plugins_loaded()
the translations in theplugins/post-smtp/Postman/languages
folder won’t be found anyway and thus won’t get translated since v3.0.1)
Hello @aqibkhan9,
Unfortunately the problem still exists. A fix that seems to work so far is to change the add_action hook in
wp-content/plugins/post-smtp/Postman/Postman.php
from ‘plugins_loaded’ to ‘init’ and add the 0 as third parameter to load it early.// hook on the plugins_loaded event
add_action( 'init', array(
$this,
'on_plugins_loaded',
), 0 );My tests didn’t cause a problem so far, but because there are really a lot of things done in the
on_plugins_loaded()
method, I’m not sure if there are some edge cases that would break things.The problem itself isn’t caused by calling
load_plugin_textdomain()
because this method simply registers the text domain’s path. The notices are thrown because of using translations with_x()
and__()
too early in other methods that are called inload_plugin_textdomain()
.- This reply was modified 2 months, 1 week ago by Ludwig C..
Hello @aqibkhan9,
Unfortunately I’m still getting the same notice when installing the beta version (2.9.12) and debug mode and display errors is enabled.
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
Warning: Cannot modify header information – headers already sent by (output started at /app/public/wp-includes/functions.php:6114) in /app/public/wp-admin/includes/misc.php on line 1438
Warning: Cannot modify header information – headers already sent by (output started at /app/public/wp-includes/functions.php:6114) in /app/public/wp-includes/functions.php on line 7137
Warning: Cannot modify header information – headers already sent by (output started at /app/public/wp-includes/functions.php:6114) in /app/public/wp-admin/admin-header.php on line 9
Hi @aqibkhan9,
We installed the beta plugin on our development environment and updated WordPress to v3.7.1 Unfortunately we’re still facing the same PHP notice:
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
Warning: Cannot modify header information - headers already sent by (output started at /app/public/wp-includes/functions.php:6114) in /app/public/wp-admin/includes/misc.php on line 1438
Warning: Cannot modify header information - headers already sent by (output started at /app/public/wp-includes/functions.php:6114) in /app/public/wp-includes/functions.php on line 7137
Warning: Cannot modify header information - headers already sent by (output started at /app/public/wp-includes/functions.php:6114) in /app/public/wp-admin/admin-header.php on line 9I am still facing the same error with FileBird Light 5.6.2, WPML 4.6.9 and PHP 8.2. So I can’t confirm that the error is fixed completely.
Deprecated: Creation of dynamic property FileBird\Support\WPML::$cpt_sync_options is deprecated in /app/public/wp-content/plugins/filebird/includes/Support/WPML.php on line 26