qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
545 stars 103 forks source link

[Slug translation module] Preview a draft post doesn't work #1358

Closed danielschwab closed 9 months ago

danielschwab commented 11 months ago

Describe the bug Previewing a draft post throws error. Tested with a custom post type (name: project, languages: de (projekt), en (project)).

`Stack trace:

0 /home/webi4se86/html/wp-content/plugins/qtranslate-xt/src/modules/slugs/slugs.php(438): QTX_Module_Slugs->get_page_by_path(NULL, 'project')

1 /home/webi4se86/html/wp-includes/class-wp-hook.php(308): QTX_Module_Slugs->filter_request(Array)

2 /home/webi4se86/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array)

3 /home/webi4se86/html/wp-includes/class-wp.php(390): apply_filters('request', Array)

4 /home/webi4se86/html/wp-includes/class-wp.php(780): WP->parse_request('')

5 /home/webi4se86/html/wp-includes/functions.php(1334): WP->main('')

6 /home/webi4se86/html/wp-blog-header.php(16): wp()

7 /home/webi4se86/html/index.php(17): require('/home/webi4se86...')

8 {main}

thrown in /home/webi4se86/html/wp-content/plugins/qtranslate-xt/src/modules/slugs/slugs.php on line 1039`

To Reproduce

  1. Go to admin post list page
  2. Click the preview link of a post with status draft
  3. See error

Expected behavior The post should be shown.

Debug info Versions

{
  "PHP_VERSION": "8.2.6",
  "WP_VERSION": "6.2.2",
  "QTX_VERSION": "3.15.2",
  "Plugins": [
    "ACF Image Sizes 1.0.0",
    "Adminimize 1.11.9",
    "Advanced Custom Fields PRO 5.8.8",
    "Classic Editor 1.6.3",
    "Custom Post Type UI 1.13.7",
    "Disable Comments 2.4.4",
    "Email Address Encoder 1.0.22",
    "Loco Translate 2.6.4",
    "Post Types Order 2.0.9",
    "qTranslate-XT 3.15.2"
  ]
}

Configuration

{
  "default_language": "de",
  "enabled_languages": [
    "de",
    "en"
  ],
  "locale": {
    "de": "de_DE",
    "en": "en_US"
  },
  "date_format": {
    "de": "%A, \\d\\e\\r %e. %B %Y",
    "en": "%A %B %e%q, %Y"
  },
  "time_format": {
    "de": "%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": false,
  "show_alternative_content": true,
  "hide_default_language": false,
  "use_secure_cookie": false,
  "header_css_on": true,
  "text_field_filters": [],
  "disable_client_cookies": false,
  "url_info": {
    "cookie_lang_front": "de",
    "cookie_lang_admin": "en",
    "cookie_front_or_admin_found": true,
    "scheme": "https",
    "host": "www.elstertainment.de",
    "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": "https://www.elstertainment.de/wp-admin/options-general.php?page=qtranslate-xt",
    "referer_admin": true,
    "doing_front_end": false,
    "lang_cookie_admin": "en",
    "lang_admin": "en",
    "language": "en",
    "set_cookie": false
  },
  "language": "en",
  "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"
  ],
  "custom_fields": [],
  "custom_field_classes": [],
  "post_type_excluded": [
    "acf-field-group",
    "acf-field"
  ],
  "admin_enabled_modules": {
    "acf": true,
    "slugs": true,
    "all-in-one-seo-pack": false,
    "events-made-easy": false,
    "jetpack": false,
    "google-site-kit": false,
    "gravity-forms": false,
    "woo-commerce": false,
    "wp-seo": false
  },
  "translator": {},
  "qtrans_compatibility": false
}

Browser

{
  "cookies": [],
  "navigator": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
  "Javascript built-in RegExp: @@split": "supported"
}
spleen1981 commented 11 months ago

Can you test the slug_fixes branch?

herrvigg commented 9 months ago

This solved the problem for another user: https://github.com/qtranslate/qtranslate-xt/pull/1363#issuecomment-1728086555

@danielschwab patch merged in master. Can you test it from there to confirm this closes the issue for you?