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

language needs to be shown in url #1068

Closed
andreysneg opened this issue Sep 17, 2021 · 5 comments
Closed

language needs to be shown in url #1068

andreysneg opened this issue Sep 17, 2021 · 5 comments
Labels
bug Something isn't working, reproducible core Core functionalities, including the admin section severity: critical Critical functionality

Comments

@andreysneg
Copy link

How disable message - "language needs to be shown in url " ?

Payment gateway Paysera.com dont work and send error:

'
Warning: assert(): language needs to be shown in url - cancelled by can_redirect, url_info={ "cookie_front_or_admin_found": false, "scheme": "https", "host": "kruvid24.ee", "path": "/", "query": "wc-api=wc_gateway_paysera", "original_url": "/?wc-api=wc_gateway_paysera", "path-base": "", "doing_front_end": true, "wp-path": "/", "doredirect": "language needs to be shown in url - cancelled by can_redirect", "language": "et", "set_cookie": true } failed in /home/kruvidee/public_html/wp-content/plugins/qtranslate-xt-master/qtranslate_core.php on line 105
OK'

@herrvigg
Copy link
Collaborator

herrvigg commented Sep 18, 2021

In theory, the assert can be commented. But this means we are in a bad state that could lead to all kind of issues. I left such asserts intentionally to understand better this kind of issues.

This error means:

  • the "expected language" is not in the URL and a redirection would be required to set the language state properly,
  • but... the redirection is not allowed because the request is on admin pages, AJAX, WP_CLI, CRON or REST.

Your request appears as "doing_front_end: true" but who is triggering this? Maybe the problem comes from "cookie_front_or_admin_found": false.

@herrvigg herrvigg added the need info The submitter must provide more info label Sep 18, 2021
@herrvigg
Copy link
Collaborator

It surely comes from the missing cookie. In that case it will try to detect the language from the browser or HTTP_REFERER, or take the default language. The error means that the resulting language does not match the URL settings. Let's say you have en as default language and the language detection finds et as shown here. Then the expected URL is /et/?wc-api=wc_gateway_paysera.

I suppose you have the front cookies enabled but why isn't the cookie set in that case? This may depend on how this request is triggered. Maybe that should be considered as a REST request? Currently it's not.

@andreysneg
Copy link
Author

I think . Instead of this message "Language needs to be shown in url" plugin must automaticaly add Default language to url and all.

Url /?wc-api=wc_gateway_paysera - make Payment plugin and impossible change this.
I had this error with other plugins too .

Now i turned on - Detect the language of the browser and redirect accordingly.
Let's see what happens.

If i comment line 446 in qtranslate_core.php what will happen ?
$url_info['doredirect'] = 'language needs to be shown in url';

or do this:
$url_info['doredirect'] = '' ;

or replace line 446 to:
$url_info['lang_browser'] = $q_config['default_language'];;

I just need no errors to appear.

@herrvigg
Copy link
Collaborator

Related to #1326.

@herrvigg
Copy link
Collaborator

Fix released in 3.14.2.

@herrvigg herrvigg added bug Something isn't working, reproducible core Core functionalities, including the admin section severity: critical Critical functionality and removed need info The submitter must provide more info labels Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, reproducible core Core functionalities, including the admin section severity: critical Critical functionality
Projects
None yet
Development

No branches or pull requests

2 participants