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
553 stars 104 forks source link

Redirections cancelled by `qtranxf_can_redirect` should not assert #1326

Closed herrvigg closed 1 year ago

herrvigg commented 1 year ago

There's an inconsistency between the qtranxf_can_redirect check and the assert that is triggered if the request can't be redirected.

The idea of assert was to notify to the user wrong requests with undefined language. However that doesn't hold well for example with AJAX requests coming from third-party plugins (not detected as admin requests), CLI commands, ... Ideally the language should be properly set, but it is impossible to assume that all plugins use the WordPress URL functions that are hooked by qTranslate such as home_url(). There might be several issues connected to that problem.

Most of the requests should still work using the default language or first in the list (to be clarified). For some cases example update requests writing in DB it could be problematic to use the wrong language but that would be a developer bug due to a wrong URL usage, not a bug from qTranslate.

For now the best is to simply skip the assert. Even a warning would be problematic for example with AJAX requests. In the future we may want to notify these cases differently for the admin for example with separate logs that won't impact the HTTP functionalities.

herrvigg commented 1 year ago

Fix released in 3.14.2. Should also fix #766, #986, #1068, #1096, #1266, #1284.