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 breaking pagination on custom post type archives #1331

Closed EdHallProper closed 1 year ago

EdHallProper commented 1 year ago

Post pagination is broken for custom post type archives and causes critical errors when paging over.

Step by step:

  1. navigate to a custom post type archive
  2. click the next button on the post pagination
  3. error appears

The Error message posted is as follows: Uncaught Error: QTX_Module_Slugs::get_page_by_path(): Argument #1 ($page_path) must be of type string, null given, called in /www/wp-content/plugins/qtranslate-xt-master/src/modules/slugs/slugs.php on line 437 in /www/wp-content/plugins/qtranslate-xt-master/src/modules/slugs/slugs.php on line 1038

Version information:{ "PHP_VERSION": "8.1.18", "WP_VERSION": "6.1.1", "QTX_VERSION": "3.15.0.dev.1", "Plugins": [ "Query Monitor 3.11.1", "Advanced Custom Fields: OpenLayers Map 1.0.0", "Advanced Custom Fields PRO 6.1.4", "Classic Editor 1.6.3", "Cloudinary 3.0.7", "Crop Thumbnails 1.5.0", "Disable \"BIG image\" Threshold 1.0", "Event Organiser 3.12.3", "qTranslate-XT 3.14.2", "Relevanssi 4.19.0", "What The File 1.6.0", "WooCommerce Additional Variation Images 2.3.0", "WooCommerce Conditional Shipping and Payments 1.14.5", "WooCommerce Stripe Gateway 7.3.0", "WooCommerce Local Pickup Plus 2.9.12", "WooCommerce 7.6.0", "Yoast SEO 20.6", "WP REST Cache 2022.2.2", "WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels (Pro) 4.3.1", "Yoast Test Helper 1.17" ] }

Configuration information: { "default_language": "en", "enabled_languages": [ "en", "cy" ], "locale": { "en": "en_GB", "cy": "cy" }, "date_format": { "en": "%A %B %e%q, %Y", "cy": "%e %B %G" }, "time_format": { "en": "%I:%M %p", "cy": "%I:%M %p" }, "url_mode": "4", "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": false, "hide_default_language": false, "use_secure_cookie": false, "header_css_on": false, "text_field_filters": [], "domains": { "en": "garden.flywheelstaging.com", "cy": "garddfotaneg.cymru" }, "disable_client_cookies": true, "url_info": { "cookie_lang_admin": "en", "cookie_front_or_admin_found": true, "scheme": "http", "host": "garden.flywheelstaging.com", "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://garden.flywheelstaging.com/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-tabs.css", "config_files": [ "./i18n-config.json" ], "custom_fields": [], "custom_field_classes": [], "post_type_excluded": [ "wc_pickup_location", "acf-field-group", "acf-field", "shop_order", "shop_order_refund", "shop_coupon" ], "admin_enabled_modules": { "acf": true, "woo-commerce": true, "wp-seo": true, "slugs": true, "all-in-one-seo-pack": false, "events-made-easy": false, "jetpack": false, "google-site-kit": false, "gravity-forms": false }, "qtrans_compatibility": false }

yoancutillas commented 1 year ago

I encounter a similar issue too:

[04-May-2023 15:09:06 UTC] PHP Warning:  Undefined array key "product" in \wp-content\plugins\qtranslate-xt\src\modules\slugs\slugs.php on line 437
[04-May-2023 15:09:06 UTC] PHP Stack trace:
[04-May-2023 15:09:06 UTC] PHP   1. {main}() \index.php:0
[04-May-2023 15:09:06 UTC] PHP   2. require() \index.php:17
[04-May-2023 15:09:06 UTC] PHP   3. wp($query_vars = *uninitialized*) \wp-blog-header.php:16
[04-May-2023 15:09:06 UTC] PHP   4. WP->main($query_args = '') \wp-includes\functions.php:1334
[04-May-2023 15:09:06 UTC] PHP   5. WP->parse_request($extra_query_vars = '') \wp-includes\class-wp.php:780
[04-May-2023 15:09:06 UTC] PHP   6. apply_filters($hook_name = 'request', $value = ['paged' => '2', 'post_type' => 'product']) \wp-includes\class-wp.php:390
[04-May-2023 15:09:06 UTC] PHP   7. WP_Hook->apply_filters($value = ['paged' => '2', 'post_type' => 'product'], $args = [0 => ['paged' => '2', 'post_type' => 'product']]) \wp-includes\plugin.php:205
[04-May-2023 15:09:06 UTC] PHP   8. QTX_Module_Slugs->filter_request($query = ['paged' => '2', 'post_type' => 'product']) \wp-includes\class-wp-hook.php:308

[04-May-2023 15:09:06 UTC] PHP Fatal error:  Uncaught TypeError: QTX_Module_Slugs::get_page_by_path(): Argument #1 ($page_path) must be of type string, null given, called in \wp-content\plugins\qtranslate-xt\src\modules\slugs\slugs.php on line 438 and defined in \wp-content\plugins\qtranslate-xt\src\modules\slugs\slugs.php:1039
Stack trace:
#0 \wp-content\plugins\qtranslate-xt\src\modules\slugs\slugs.php(438): QTX_Module_Slugs->get_page_by_path(NULL, 'product')
#1 \wp-includes\class-wp-hook.php(308): QTX_Module_Slugs->filter_request(Array)
#2 \wp-includes\plugin.php(205): WP_Hook->apply_filters(Array, Array)
#3 \wp-includes\class-wp.php(390): apply_filters('request', Array)
#4 \wp-includes\class-wp.php(780): WP->parse_request('')
#5 \wp-includes\functions.php(1334): WP->main('')
#6 \wp-blog-header.php(16): wp()
#7 \index.php(17): require('...')
#8 {main}
  thrown in \wp-content\plugins\qtranslate-xt\src\modules\slugs\slugs.php on line 1039```

This error is triggered when visiting page 2 of the products loop page (with WooCommerce, usually yoursite.com/en/shop).

My permalinks settings are: Permalink structure = Post name Product permalinks = Shop base

URL Modification Mode = Use Pre-Path Mode (Default, puts /en/ in front of URL). SEO friendly.

PHP 8.0.29, QTX 3.15.1

spleen1981 commented 1 year ago

can you check if 5bdb963b1bb372031575109f32a0ddea68dd25a7 is fixing the issue?

yoancutillas commented 1 year ago

This is fixing the issue in my case, thank you :)

herrvigg commented 1 year ago

@EdHallProper could you check if this fix also solves the issue for you? It's not been released yet but it's available in the master branch which you can also download.

herrvigg commented 1 year ago

Released in 3.15.2.