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

[Admin module?] PHP Error with Wordpress 6.7 in the admin: Translation loading for the qtranslate domain was triggered too early #1422

Open
yoancutillas opened this issue Nov 13, 2024 · 3 comments
Labels
maybe bug Potential bug, to be investigated

Comments

@yoancutillas
Copy link

yoancutillas commented Nov 13, 2024

Describe the bug
With Wordpress 6.7, this PHP error appears in PHP logs:

[13-Nov-2024 10:48:29 UTC] PHP Notice:  Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>qtranslate</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
[13-Nov-2024 10:48:29 UTC] PHP Stack trace:
[13-Nov-2024 10:48:29 UTC] PHP   1. {main}() \wp-admin\admin.php:0
[13-Nov-2024 10:48:29 UTC] PHP   2. require_once() \wp-admin\admin.php:34
[13-Nov-2024 10:48:29 UTC] PHP   3. require_once() \wp-load.php:50
[13-Nov-2024 10:48:29 UTC] PHP   4. require_once() \wp-config.php:102
[13-Nov-2024 10:48:29 UTC] PHP   5. do_action($hook_name = 'plugins_loaded') \wp-settings.php:559
[13-Nov-2024 10:48:29 UTC] PHP   6. WP_Hook->do_action($args = [0 => '']) \wp-includes\plugin.php:517
[13-Nov-2024 10:48:29 UTC] PHP   7. WP_Hook->apply_filters($value = '', $args = [0 => '']) \wp-includes\class-wp-hook.php:348
[13-Nov-2024 10:48:29 UTC] PHP   8. qtranxf_init_language('') \wp-includes\class-wp-hook.php:324
[13-Nov-2024 10:48:29 UTC] PHP   9. qtranxf_admin_load() \wp-content\plugins\qtranslate-xt\src\init.php:129
[13-Nov-2024 10:48:29 UTC] PHP  10. qtranxf_admin_load_config() \wp-content\plugins\qtranslate-xt\src\admin\admin.php:834
[13-Nov-2024 10:48:29 UTC] PHP  11. qtranxf_admin_set_default_options($options = ['front' => ['int' => [...], 'bool' => [...], 'str' => [...], 'text' => [...], 'array' => [...]], 'default_value' => ['default_language' => NULL, 'enabled_languages' => NULL, 'qtrans_compatibility' => FALSE, 'disable_client_cookies' => FALSE, 'flag_location' => NULL, 'filter_options' => 'blogname blogdescription widget_%', 'ignore_file_types' => 'gif,jpg,jpeg,png,svg,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js,mp3,mp4,apk', 'domains' => NULL], 'languages' => ['language_name' => 'qtranslate_language_names', 'locale' => 'qtranslate_locales', 'locale_html' => 'qtranslate_locales_html', 'not_available' => 'qtranslate_na_messages', 'date_format' => 'qtranslate_date_formats', 'time_format' => 'qtranslate_time_formats', 'flag' => 'qtranslate_flags'], 'admin' => ['int' => [...], 'bool' => [...], 'str' => [...], 'text' => [...], 'array' => [...], 'admin_enabled_modules' => [...]]]) \wp-content\plugins\qtranslate-xt\src\admin\admin_options.php:54
[13-Nov-2024 10:48:29 UTC] PHP  12. QTX_Admin_Module::get_modules() \wp-content\plugins\qtranslate-xt\src\admin\admin_options.php:44
[13-Nov-2024 10:48:29 UTC] PHP  13. QTX_Admin_Module::get_builtin_setup() \wp-content\plugins\qtranslate-xt\src\modules\admin_module.php:148
[13-Nov-2024 10:48:29 UTC] PHP  14. __($text = 'Slugs translation', $domain = 'qtranslate') \wp-content\plugins\qtranslate-xt\src\modules\admin_module.php:130
[13-Nov-2024 10:48:29 UTC] PHP  15. translate($text = 'Slugs translation', $domain = 'qtranslate') \wp-includes\l10n.php:306
[13-Nov-2024 10:48:29 UTC] PHP  16. get_translations_for_domain($domain = 'qtranslate') \wp-includes\l10n.php:194
[13-Nov-2024 10:48:29 UTC] PHP  17. _load_textdomain_just_in_time($domain = 'qtranslate') \wp-includes\l10n.php:1385
[13-Nov-2024 10:48:29 UTC] PHP  18. _doing_it_wrong($function_name = '_load_textdomain_just_in_time', $message = 'Translation loading for the <code>qtranslate</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.', $version = '6.7.0') \wp-includes\l10n.php:1347
[13-Nov-2024 10:48:29 UTC] PHP  19. wp_trigger_error($function_name = '', $message = 'Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>qtranslate</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.)', $error_level = *uninitialized*) \wp-includes\functions.php:6054
[13-Nov-2024 10:48:29 UTC] PHP  20. trigger_error($message = 'Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>qtranslate</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.)', $error_level = 1024) \wp-includes\functions.php:6114

To Reproduce
Steps to reproduce the behavior:

  1. Update to Wordpress 6.7
  2. Use qTranslate XT

Expected behavior
No PHP error should appear.

Screenshots

Debug info

Versions
{
  "PHP_VERSION": "8.2.23",
  "WP_VERSION": "6.7",
  "QTX_VERSION": "3.15.2",
  "Plugins": [
    "Booking Activities - Advanced Forms 1.4.6",
    "Booking Activities - Display Pack 1.5.6",
    "Booking Activities - Licenses &amp; Updates 1.2.12",
    "Booking Activities - Notification Pack 1.3.7",
    "Booking Activities - Order For Customers 1.3.3",
    "Booking Activities - Prices and Credits 1.8.20",
    "Booking Activities - Resource Availability 1.1.8",
    "Booking Activities 1.16.22",
    "Check &amp; Log Email 2.0.3",
    "qTranslate-XT 3.15.2",
    "User Role Editor 4.64.2",
    "Payment Plugins for Stripe WooCommerce 3.3.77",
    "WooCommerce 9.4.1"
  ]
}
Configuration
{
  "default_language": "fr",
  "enabled_languages": [
    "fr",
    "en"
  ],
  "locale": {
    "fr": "fr_FR",
    "en": "en_US"
  },
  "date_format": {
    "fr": "%A %e %B %Y",
    "en": "%A %B %e%q, %Y"
  },
  "time_format": {
    "fr": "%H:%M",
    "en": "%I:%M %p"
  },
  "url_mode": 2,
  "use_strftime": 3,
  "filter_options_mode": 0,
  "language_name_case": 0,
  "detect_browser_language": true,
  "hide_untranslated": false,
  "show_menu_alternative_language": false,
  "show_displayed_language_prefix": true,
  "show_alternative_content": false,
  "hide_default_language": true,
  "use_secure_cookie": false,
  "header_css_on": true,
  "text_field_filters": [],
  "disable_client_cookies": false,
  "url_info": {
    "cookie_lang_front": "fr",
    "cookie_lang_admin": "fr",
    "cookie_front_or_admin_found": true,
    "scheme": "http",
    "host": "dev.booking-activities.yc",
    "path": "/wp-admin/admin-ajax.php",
    "query": "action=admin_debug_info",
    "path-base": "",
    "wp-path": "/wp-admin/admin-ajax.php",
    "language_neutral_path": true,
    "http_referer": "http://dev.booking-activities.yc/wp-admin/options-general.php?page=qtranslate-xt",
    "referer_admin": true,
    "doing_front_end": false,
    "lang_cookie_admin": "fr",
    "lang_admin": "fr",
    "language": "fr",
    "set_cookie": false
  },
  "language": "fr",
  "editor_mode": 0,
  "highlight_mode": 1,
  "auto_update_mo": true,
  "hide_lsb_copy_content": false,
  "lsb_style": "simple-buttons.css",
  "config_files": [
    "./i18n-config.json",
    "./plugins/booking-activities/i18n-config.json",
    "./plugins/ba-advanced-forms/i18n-config.json",
    "./plugins/ba-display-pack/i18n-config.json",
    "./plugins/ba-notification-pack/i18n-config.json",
    "./plugins/ba-order-for-customers/i18n-config.json",
    "./plugins/ba-prices-and-credits/i18n-config.json",
    "./plugins/ba-resource-availability/i18n-config.json"
  ],
  "custom_fields": [],
  "custom_field_classes": [],
  "post_type_excluded": [],
  "admin_enabled_modules": {
    "woo-commerce": true,
    "acf": false,
    "all-in-one-seo-pack": false,
    "events-made-easy": false,
    "jetpack": false,
    "google-site-kit": false,
    "gravity-forms": false,
    "wp-seo": false,
    "slugs": false
  },
  "translator": {},
  "qtrans_compatibility": false
}
Browser
{
  "cookies": [],
  "navigator": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
  "Javascript built-in RegExp: @@split": "supported"
}

Edit: This issue is not related to the string that were not translated, and to the Slug module, so I have updated the bug description.

@yoancutillas yoancutillas added the maybe bug Potential bug, to be investigated label Nov 13, 2024
@yoancutillas yoancutillas changed the title [Slug module?] [Admin module?] Not working properly with Wordpress 6.7 in the admin [Admin module?] PHP Error with Wordpress 6.7 in the admin: Translation loading for the qtranslate domain was triggered too early Nov 14, 2024
@rg-
Copy link

rg- commented Nov 14, 2024

Having that problem after updated WP TO 6.7, and i ended changing (src/init.php)

qtranxf_load_plugin_textdomain();

TO JUST:

add_action( 'init', function(){
qtranxf_load_plugin_textdomain();
} );

And for now, everything is working ok. I hope!

@bagaweb
Copy link

bagaweb commented Nov 15, 2024

At the moment I can't see any error messages with WP 6.7 and QTX 3.15.2.

@yoancutillas
Copy link
Author

I confirm that replacing https://github.com/qtranslate/qtranslate-xt/blob/3.15.2/src/init.php#L112-L117

    // TODO delay to `init` action?
    // See https://developer.wordpress.org/reference/functions/load_plugin_textdomain/
    // Loading the plugin translations should not be done during plugins_loaded action since that is too early and prevent
    // other language related plugins from correctly hooking up with load_textdomain() function and doing whatever they want to do.
    // Calling load_plugin_textdomain() should be delayed until init action.
    qtranxf_load_plugin_textdomain();

with

add_action( 'init', 'qtranxf_load_plugin_textdomain' );

fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maybe bug Potential bug, to be investigated
Projects
None yet
Development

No branches or pull requests

3 participants