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

AJAX response error in Advanced Woo Search plugin under PHP8+ #1284

Closed
Komarovski opened this issue Feb 8, 2023 · 7 comments
Closed

AJAX response error in Advanced Woo Search plugin under PHP8+ #1284

Komarovski opened this issue Feb 8, 2023 · 7 comments
Labels
bug Something isn't working, reproducible core Core functionalities, including the admin section severity: critical Critical functionality

Comments

@Komarovski
Copy link
Contributor

Hey everyone,

Author of "Advanced Woo Search" plugin is asking - is qTranslate-XT provides some option to exclude some URLs from its language redirections?

Here's the link to a thread I've started on WP: https://wordpress.org/support/topic/ajax-doesnt-work-under-php8/#post-16451942

The problem is next, when I run website on PHP 7.4 "qTranslate-XT" and "Advanced Woo Search" works fine, but when I'm swithing to PHP 8+ versions and starting to search some products with "Advanced Woo Search", in browser console log I get an error: POST https://antik.ua/?wc-ajax=aws_action 500 jquery-3-6-0.min.js:2

After debuggin I saw that qTranslate-XT on PHP8+ trows an "CRITICAL Uncaught AssertionError".

2023-02-08T08:26:50+00:00 CRITICAL Uncaught AssertionError: detected in parse_language_info - cancelled by can_redirect, url_info={
"cookie_lang_front": "ru",
"cookie_front_or_admin_found": true,
"scheme": "https",
"host": "antik.ua",
"path": "\/",
"query": "wc-ajax=aws_action",
"path-base": "",
"doing_front_end": true,
"wp-path": "\/",
"language": "ru",
"doredirect": "detected in parse_language_info - cancelled by can_redirect",
"set_cookie": true
} in /home/antikua/antik.ua/www/wp-content/plugins/qtranslate-xt/qtranslate_core.php:102
Stack trace:

0 /home/antikua/antik.ua/www/wp-content/plugins/qtranslate-xt/qtranslate_core.php(102): assert(false, 'detected in par…')

1 /home/antikua/antik.ua/www/wp-includes/class-wp-hook.php(308): qtranxf_init_language('')

2 /home/antikua/antik.ua/www/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)

3 /home/antikua/antik.ua/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array)

4 /home/antikua/antik.ua/www/wp-settings.php(480): do_action('plugins_loaded')

5 /home/antikua/antik.ua/www/wp-config.php(100): require_once('/home/antikua/a…')

6 /home/antikua/antik.ua/www/wp-load.php(50): require_once('/home/antikua/a…')

7 /home/antikua/antik.ua/www/wp-blog-header.php(13): require_once('/home/antikua/a…')

8 /home/antikua/antik.ua/www/index.php(17): require('/home/antikua/a…')

9 {main}

thrown in /home/antikua/antik.ua/www/wp-content/plugins/qtranslate-xt/qtranslate_core.php on line 102

Can anyone help me to understand what could lead to this error in PHP 8+ and didn't lead to such error in PHP 7.4?

Thanks!

@herrvigg
Copy link
Collaborator

That's annoying, there should be no redirection possible on AJAX calls. Nothing specific to PHP8 comes to my mind.

@herrvigg herrvigg added the core Core functionalities, including the admin section label Mar 25, 2023
@Komarovski
Copy link
Contributor Author

I have found that same "AssertionError" already was in PHP7 too, but in PHP8 it throws warning by default. Here's some info that I found about "AssertionError" in PHP8: https://php.watch/versions/8.0/assert-throws

Right now I have commented assert function in qtranslate_core.php on line 102. And everything's working on the frontend.

I think we should add some option that will allow users to turn on the development mode, and by default plugin will have production mode enabled - and all this assert checks will be ignored. Since not every hosting provides ability to change INI settings to disable assertation checks.

@herrvigg
Copy link
Collaborator

Can you check if you have HTTP_X_REQUESTED_WITH = XMLHttpRequest passed in the Ajax request? Or the same parameter without X.

I have no explanation about the PHP version though. You may compare the requests.

@herrvigg
Copy link
Collaborator

See #1326.

@herrvigg
Copy link
Collaborator

Fix released in 3.14.2.

I found the explanation about PHP8.0: https://php.watch/versions/8.0/assert-throws.
The default setting of PHP INI has changed to assert.exception=1 from 0 before. That means the assert triggers an exception instead of a simple warning.
This is poorly documented from the official PHP.net, nothing in the PHP8.0 release notes... only in a separate doc about PHP8.0 incompatibilties . See also this patch in github: php/php-src#5925.

@herrvigg herrvigg added bug Something isn't working, reproducible severity: critical Critical functionality labels Apr 19, 2023
@herrvigg
Copy link
Collaborator

I missed your earlier response about exceptions in PHP8.0... but we came to the same conclusion :)

@Komarovski
Copy link
Contributor Author

I missed your earlier response about exceptions in PHP8.0... but we came to the same conclusion :)

Hey Herr Vigg, sorry for late reply, yep, in latest version everything works fine with PHP8+, thank you very much for this fix! :)

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