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
546 stars 103 forks source link

[Slug translation module] page not found when changes slug translation #1348

Open nalato opened 1 year ago

nalato commented 1 year ago

Describe the bug When i change the slug translations, the default url doesn't works with the secondary languges. I think the default slug/url depend to the first page publishing and doesn't changes when I rename the slug's translation.

To Reproduce Steps to reproduce the behavior(with the option "hide default language" activated): 1) I create a page with the title "Test page" and I publish it. Therefore the slug is set automatically to "test-page" 2) Then I change the language slug: IT > pagina-di-test, EN > test-page-test, DE > testseite 3) In the front-end I set the main language (IT for me): https://www.blowtherm.it/pagina-di-test/ works. 4) I change the language to EN and I click this link: https://www.blowtherm.it/pagina-di-test/ doesn't works but https://www.blowtherm.it/en/test-page-test/ works

Expected behavior I expects that when I change the slug's translation, this change also the default page url or I need the possobility to change the default slug.

Solution (for me): 1) I disable the slug translation module 2) I rename the default slug (for my example "test-page" to "pagina-di-test" 3) I reactivate the slug translation module 4) This works for all languages

Debug info Versions { "PHP_VERSION": "7.4.33", "WP_VERSION": "6.2.2", "QTX_VERSION": "3.15.1", "Plugins": [ "Git Updater 12.2.2", "Map List Pro 3.12.11", "Advanced CF7 DB 1.9.3", "Advanced Custom Fields PRO 5.12.3", "Ajax Search Lite 4.11.2", "All In One SEO Pack Pro 3.7.1", "Animate It! 3.0.2", "Better Internal Link Search 1.3.0", "Breadcrumb NavXT 7.2.0", "Conditional Fields for Contact Form 7 2.3.9", "Contact Form 7 Countries 1.0.0", "Classic Editor 1.6.3", "Admin Columns 4.6.1", "Complianz | GDPR/CCPA Cookie Consent 6.4.6", "Contact Form 7 - Dynamic Text Extension 3.2", "Contact Form 7 5.7.7", "Drag and Drop Multiple File Upload - Contact Form 7 1.3.6.9", "Yoast Duplicate Post 4.5", "GTM4WP 1.16.2", "Email Encoder - Protect Email Addresses 2.1.6", "Email Log 2.4.8", "Email Templates 1.4.2", "Enable Media Replace 4.1.2", "Favicon by RealFaviconGenerator 1.3.27", "Flamingo 2.4", "Floating Awesome Button 1.6.1", "Header Footer Code Manager 1.1.32", "Listo 1.6", "LiteSpeed Cache 5.4", "Loco Translate 2.6.4", "MC4WP: Mailchimp for WordPress 4.9.5", "Popup Maker 1.18.1", "Post Types Order 2.0.9", "Public Post Preview 2.10.0", "qTranslate-XT 3.15.1", "Regenerate Thumbnails 3.1.5", "Relevanssi 4.20.0", "SEO Redirection Premium 3.7", "Simple Page Ordering 2.5.1", "Category Order and Taxonomy Terms Order 1.7.7", "Advanced Editor Tools 5.9.0", "Visual Term Description Editor 1.8.1", "Wordfence Security 7.9.3", "WP Consent API 1.0.6", "WP Mail SMTP 3.8.0", "Embed Plus YouTube WordPress Plugin 14.1.6.2" ] } Configuration { "default_language": "it", "enabled_languages": [ "it", "en", "de" ], "locale": { "it": "it_IT", "en": "en_US", "de": "de_DE" }, "date_format": { "it": "%e %B %Y", "en": "%A %B %e%q, %Y", "de": "%A, \d\e\r %e. %B %Y" }, "time_format": { "it": "%H:%M", "en": "%I:%M %p", "de": "%H:%M" }, "url_mode": 2, "use_strftime": 3, "filter_options_mode": 0, "language_name_case": "1", "detect_browser_language": false, "hide_untranslated": false, "show_menu_alternative_language": false, "show_displayed_language_prefix": false, "show_alternative_content": true, "hide_default_language": true, "use_secure_cookie": false, "header_css_on": true, "text_field_filters": [], "disable_client_cookies": false, "url_info": { "cookie_lang_front": "it", "cookie_lang_admin": "it", "cookie_front_or_admin_found": true, "scheme": "https", "host": "www.blowtherm.it", "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.blowtherm.it/wp-admin/options-general.php?page=qtranslate-xt", "referer_admin": true, "doing_front_end": false, "lang_cookie_admin": "it", "lang_admin": "it", "language": "it", "set_cookie": false }, "language": "it", "editor_mode": 0, "highlight_mode": "9", "auto_update_mo": true, "hide_lsb_copy_content": true, "lsb_style": "simple-buttons.css", "highlight_mode_custom_css": "input.qtranxs-translatable, textarea.qtranxs-translatable, div.qtranxs-translatable, div.multi-language-field textarea, div.multi-language-field input {\nborder-left: 3px solid #UserColor2 !important;\n}\n.multi-language-field { margin-top: 0;}\n", "config_files": [ "./i18n-config.json", "./i18n-config/plugins/mailchimp-for-wp/i18n-config.json", "./i18n-config/plugins/mailchimp-for-wp/i18n-config.json" ], "custom_fields": [ "field_fab_setting_link" ], "custom_field_classes": [], "post_type_excluded": [ "custom_css", "customize_changeset", "oembed_cache", "user_request", "wp_block", "wp_template", "wp_template_part", "wp_global_styles", "popup_theme", "acf-field-group", "acf-field", "wpcf7_contact_form", "flamingo_contact", "flamingo_inbound", "mc4wp-form" ], "admin_enabled_modules": { "acf": true, "all-in-one-seo-pack": true, "slugs": true, "events-made-easy": false, "jetpack": false, "google-site-kit": false, "gravity-forms": false, "woo-commerce": false, "wp-seo": false }, "qtrans_compatibility": false } Browser { "cookies": [], "navigator": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0", "Javascript built-in RegExp: @@split": "supported" }

herrvigg commented 1 year ago

Looks specific to slugs module. Perhaps @spleen1981 (who knows this module the best) can take a look. Good you found a workaround.

spleen1981 commented 1 year ago

When i change the slug translations, the default url doesn't works with the secondary languges.

@nalato do you get 404?

spleen1981 commented 11 months ago

This should be same issue as #1328. Actually the language switcher would provide https://www.blowtherm.it/it/pagina-di-test/ in the example above (without the it omitted), which works. The workaround above works because original slugs are still functional with slugs module enabled (i.e. https://www.blowtherm.it/en/test-page/ would work as well)

spleen1981 commented 11 months ago

@nalato can you test fix_language_detect_slugs branch?

nalato commented 11 months ago

@spleen1981 I uploaded and tested the new branch, but there is a new problem:

  1. In the front-end I set the main language (IT for me): https://www.blowtherm.it/pagina-di-test/ works.
  2. I change the language to EN and I click this link: https://www.blowtherm.it/pagina-di-test/ works
  3. I change the language to IT and then to EN page not found (https://www.blowtherm.it/it/?page_id=11690 or also https://www.blowtherm.it/pagina-di-test/)
spleen1981 commented 11 months ago

@nalato assuming that when you say "I set / I change" you mean switching the front language using QTX language switch widget, I'm not able to replicate this, in my test environment it works fine switching back and forth.

You may try again flushing all caches, flushing rewrite rules (settings > permalink > save) and maybe using a new test page.

nalato commented 10 months ago

@spleen1981 sorry for the delay, I tested the new branch and I created a new page. Now it works for me. But I found a new problem in a draft custom type post, with the preview link. The standard post preview works fine.

Example: https://www.blowtherm.it/?p=11904&post_type=progetto&preview=1&_ppp=eb2e867baf (this is a public preview) https://www.blowtherm.it/?post_type=progetto&p=11904&preview=true (this is a standard admin only preview)

Fatal error: Uncaught TypeError: Argument 1 passed to QTX_Module_Slugs::get_page_by_path() must be of the type string, null given, called in /home1/blowther/public_html/wp-content/plugins/qtranslate-xt/src/modules/slugs/slugs.php on line 438 and defined in /home1/blowther/public_html/wp-content/plugins/qtranslate-xt/src/modules/slugs/slugs.php:1039 Stack trace: #0 /home1/blowther/public_html/wp-content/plugins/qtranslate-xt/src/modules/slugs/slugs.php(438): QTX_Module_Slugs->get_page_by_path(NULL, 'progetto') #1 /home1/blowther/public_html/wp-includes/class-wp-hook.php(310): QTX_Module_Slugs->filter_request(Array) #2 /home1/blowther/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #3 /home1/blowther/public_html/wp-includes/class-wp.php(389): apply_filters('request', Array) #4 /home1/blowther/public_html/wp-includes/class-wp.php(779): WP->parse_request('') #5 /home1/blowther/public_html/wp-includes/functions.php(1335): WP->main('') #6 /home1/blowther/public_html/wp-blog-header.php(16): wp() #7 in /home1/blowther/public_html/wp-content/plugins/qtranslate-xt/src/modules/slugs/slugs.php on line 1039

spleen1981 commented 10 months ago

This last issue is fixed by #1363. To test all together, you should manually merge #1363 and #1364 commits to your local repo, or wait @herrvigg to possibly merge those PR to master.

herrvigg commented 8 months ago

I can reproduce the problem so I confirm it's a bug. We can't merge the #1364 fix in the current state because it's creating some regressions.

This should be same issue as https://github.com/qtranslate/qtranslate-xt/issues/1328.

I'm not sure this is the same as #1328 which involves browser auto-detection, which is different than language switch from URL and it's more difficult to test.

Actually the language switcher would provide https://www.blowtherm.it/it/pagina-di-test/ in the example above (without the it omitted), which works.

Good if the switcher gives the correct URL with slugs. Still the issue is relevant enough, if we enter manually the URL or if there are some "manual links" that omit the language. If there are other problems with the switcher please create another ticket.

spleen1981 commented 4 months ago

https://github.com/qtranslate/qtranslate-xt/pull/1364 regressions should be fixed now