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

Error on login redirect #749

Closed
hirasso opened this issue Oct 28, 2019 · 6 comments
Closed

Error on login redirect #749

hirasso opened this issue Oct 28, 2019 · 6 comments
Labels
core Core functionalities, including the admin section

Comments

@hirasso
Copy link

hirasso commented Oct 28, 2019

Hi there, just noticed an error when trying to log in to my WordPress admin:

Warning: assert(): language needs to be shown in url - cancelled by can_redirect failed in /xxx/content/plugins/qtranslate-xt/qtranslate_core.php on line 109

This only happens when logging in. If I am already logged in, the error is not being thrown. WordPress 5.2.4, qtranslate-xt 3.7.1.

@herrvigg
Copy link
Collaborator

herrvigg commented Nov 2, 2019

Yes i can reproduce this. Thanks for reporting!

This should not have any strong effect in production mode, but the goal of the asserts is to detect all these unexpected cases, that were kind of hidden (putting the dust under the carpet) until i added this.

@herrvigg
Copy link
Collaborator

herrvigg commented Nov 3, 2019

I think i have understood the problem. It happens when you try to login while having a non-default language in the front cookie. If you switch to the default language and try to login again you won't have the problem.

But having a different language can happen. For a normal page this should lead to a redirection, but in the case of a POST request this is not allowed. I was first thinking a special case could be added for the login request having a "redirect_to" in the POST data. However, the problem seems even more general for the so-called neutral URL path, for which the language should not be enforced. The wp-login URL is part of that group. See function qtranxf_language_neutral_path.

It is quite tricky to understand all the cases and how to handle them because some are done in the detection and others later on (needs a lot refactoring), but as i see it when the language is detected from the front cookie, we should not even try to redirect when the URL concerns a neutral URL. We should just take the language as it is. I hope this won't break other things but this would be inconsistent with the concept of neutral URL path.

@herrvigg herrvigg added the core Core functionalities, including the admin section label Nov 3, 2019
@herrvigg
Copy link
Collaborator

herrvigg commented Nov 3, 2019

Fixed in master, testers are welcome to try this.

@herrvigg herrvigg closed this as completed Nov 3, 2019
@hirasso
Copy link
Author

hirasso commented Nov 4, 2019

Nice one, works now! Thanks for your quick fix!!

@williamli
Copy link

@herrvigg I still see this error when I use wp-cli to run scripts on the wordpress installation

image

@raptor235
Copy link

@herrvigg same here seeing this in cli commands as a fatal error in 8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionalities, including the admin section
Projects
None yet
Development

No branches or pull requests

4 participants