Make WordPress Core

Opened 2 months ago

Closed 2 months ago

Last modified 2 months ago

#64401 closed defect (bug) (invalid)

Function _load_textdomain_just_in_time was called incorrectly

Reported by: arifursdev's profile arifursdev Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.7
Component: I18N Keywords:
Focuses: Cc:

Description

Hello, in my plugin, despite loading the textdomain on init action

<?php

add_action( 'init', [$this, 'load_text_domain'] );

public static function load_text_domain() {
    load_plugin_textdomain( 'TOLS_ACTIVITY_MANAGER', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
}

I keep on getting the notice in wp-content/debug.log file.

[10-Dec-2025 08:39:57 UTC] PHP Notice:  Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>TOLS_ACTIVITY_MANAGER</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 D:\xampp\htdocs\wp_quickstart\wp-includes\functions.php on line 6131

and I cannot tell which version, but recently it seems after the WordPress updates, it has become impossible to stop notices or control which errors should be put to debug.log file. despite doing this in wp-config.php file, it keeps on logging PHP Notices. even edited the php.ini file locally, error reporting on the hosting level, it just keeps on logging.

<?php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
ini_set('display_errors', 'off');
error_reporting( E_ALL & ~E_NOTICE );

Currently I'm using the latest version (6.9)

Change History (2)

#1 follow-up: @swissspidy
2 months ago

  • Component changed from Plugins to I18N
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Severity changed from major to normal
  • Status changed from new to closed
  • Version changed from 6.9 to 6.7

As the error message says:

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.

The code you shared does not cause any warning by itself, so there is something else going on. For example a call to __() on an earlier hook, or some other plugin interfering with yours.

See https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/ for details and suggested debugging steps. If you share your plugin I'm also happy to help.

it just keeps on logging.

Try turning off WP_DEBUG.

For further assistance I suggest asking in the support forums.

#2 in reply to: ↑ 1 @arifursdev
2 months ago

Replying to swissspidy:

The code you shared does not cause any warning by itself, so there is something else going on. For example a call to __() on an earlier hook, or some other plugin interfering with yours.

Well It seems translate functions are running and trying to load the translations before init, when the function is somewhere used before loading the translation.

Try turning off WP_DEBUG.

I know but I would like to log others errors and warnings, not notices.

Note: See TracTickets for help on using tickets.