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

NextGen Gallery uploader not working #1266

Closed
HoriaMarusca opened this issue Dec 7, 2022 · 12 comments
Closed

NextGen Gallery uploader not working #1266

HoriaMarusca opened this issue Dec 7, 2022 · 12 comments
Labels
bug Something isn't working, reproducible good first issue Good for newcomers plugin: others Concerns integration with other plugins severity: critical Critical functionality

Comments

@HoriaMarusca
Copy link

HoriaMarusca commented Dec 7, 2022

Intro: I am not a programmer, I am a (web) designer. I use the browser DevTools mainly to work on css styling. My knowledge in using debugging tools is limited.

The problem (probably similar with #1096?)

Environment:

Wordpress 6.1.1
PHP 8.0.26
Qtranslate XT ver 3.12.1 (with Yoast SEO 19.11, ACF 6.0.5, Slugs translation built-in modules activated)
NextGen Gallery ver 3.3.0

Short description:
Failing to upload images using the Nextgen upload function. The WordPress uploader works correctly.

Long description:
The problem appears in the admin area of WordPress, only when using the Nextgen uploader. After dropping the files for upload (or selecting the files using the "Browser" button) and hitting the "Upload" button, the upload progress is shown as going from 0 to 100%, but in the end the upload fails.

The error message I get in the Chrome/Developer Tools/Network/Fetch/XHR is this one:

AssertionError thrown

language needs to be shown in url - cancelled by can_redirect, url_info={ "cookie_lang_front": "en", "cookie_front_or_admin_found": true, "scheme": "https", "host": "mywebsite", "path": "\/index.php", "query": "photocrati_ajax=1", "path-base": "", "doing_front_end": true, "wp-path": "\/index.php", "lang_cookie_front": "en", "doredirect": "language needs to be shown in url - cancelled by can_redirect", "language": "en", "set_cookie": true }

This might very well be a problem with NextGen, and not with Qtranslate XT. But if I deactivate the Qtranslate XT plugin, the problem disappears. I tried deactivating the Qtranslate XT built-in modules, but no luck. I also tried deactivating other plugins, again no luck.

It's "language needs to be shown in url" that makes me believe it is related to Qtranslate XT.

@herrvigg
Copy link
Collaborator

See also #1096 though it looks like a different issue.

@herrvigg herrvigg added the plugin: others Concerns integration with other plugins label Apr 2, 2023
@HoriaMarusca
Copy link
Author

It looks like activating "Hide URL language information for default language" in qtranslate-XT options / General / URL Modification Mode solves the problem/

@herrvigg herrvigg added the good first issue Good for newcomers label Apr 9, 2023
@herrvigg
Copy link
Collaborator

herrvigg commented Apr 9, 2023

Thanks for the info, that's useful. I'll look into it.

@HoriaMarusca
Copy link
Author

HoriaMarusca commented Apr 9, 2023

This is the error message sent by Wordpress that made me think of selecting the option with hiding the url (notice the double slash character between 'domain.com' and 'wp-admin'):

`Howdy!

WordPress caught an error with one of your plugins, qTranslate-XT.

The page where the error was caught (http://www.domain.com/wp-login.php?redirect_to=https://domain.com//wp-admin/) and check for any visible issues.

[...]

WordPress version 6.1.1
Active theme: custom
Current plugin: qTranslate-XT (version 3.13.0)
PHP version 8.2.4

Error Details

An error of type E_ERROR was caused in line 102 of the file .../wp-content/plugins/qtranslate-xt-3.13.0 - ian 05 2023/qtranslate_core.php. Error message: Uncaught AssertionError: language needs to be shown in url - cancelled by can_redirect, url_info={
"cookie_front_or_admin_found": false,
"scheme": "http",
"host": "domain.com",
"path": "//wp-login.php",
"query": "redirect_to=https://domain.com//wp-admin/",
"path-base": "",
"doing_front_end": true,
"wp-path": "//wp-login.php",
"lang_browser": "en",
"doredirect": "language needs to be shown in url - cancelled by can_redirect",
"language": "en",
"set_cookie": true
} in .../wp-content/plugins/qtranslate-xt-3.13.0 - ian 05 2023/qtranslate_core.php:102
Stack trace:
0 .../wp-content/plugins/qtranslate-xt-3.13.0 - ian 05 2023/qtranslate_core.php(102): assert()
1 .../wp-includes/class-wp-hook.php(308): qtranxf_init_language()
2 .../wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
3 .../wp-includes/plugin.php(517): WP_Hook->do_action()
4 .../wp-settings.php(480): do_action()
5 .../wp-config.php(89): require_once('/...')
6 .../wp-load.php(50): require_once('/...')
7 .../wp-login.php(12): require('/...')
8 {main}
thrown`

@herrvigg
Copy link
Collaborator

The problem is clear, the requested URI is "wrong" in the sense it doesn't contain the language, but at the same time the request is not detected as AJAX by qTranslate.

I have a solution on the table, to check HTTP_X_REQUESTED_WITH = XMLHttpRequest (generally it's that value). I'm baffled this wasn't in place before... Checking DOING_AJAX is definitely not enough, this is only valid for the WordPress Ajax requests, but not for all the other plugins.

Even the assert on the redirect is wrong with Ajax requests. So there's quite a bit to fix and test here. But this could solve many related issues.

See also RFC6648: the X in HTTP_X_REQUESTED_WITH is deprecated so we should support both.

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

Happy to help with testing, if needed, on my dev WordPress site (NextGen, Qtranslate XT, custom theme). That's pretty much where my area of expertise ends.

@herrvigg
Copy link
Collaborator

See #1326.

@herrvigg
Copy link
Collaborator

herrvigg commented Apr 17, 2023

You can test from this tree:
https://github.com/qtranslate/qtranslate-xt/tree/8c9e672040bb0acaa1c333ebcedab6080d70db21
I have not release it yet and it will go to upcoming 3.14.2. It's not merged in master yet because the hotfix is on the 3.14.x line and master is already in 3.15.x.

The main fix is trivial, it's only about removing an assert. But there's more behind the scenes. I first thought about a missed AJAX detection that is now mentioned in #1327 but that's actually a different topic.

@herrvigg
Copy link
Collaborator

Or even better with this, just with another minor fix but that should work the same:
https://github.com/qtranslate/qtranslate-xt/tree/b2b7c1600d9fe1369e61b0622691eeb7c314046e

@HoriaMarusca
Copy link
Author

Or even better with this, just with another minor fix but that should work the same: https://github.com/qtranslate/qtranslate-xt/tree/b2b7c1600d9fe1369e61b0622691eeb7c314046e

With the version above of qtranslate XT (b2b7c16) the NextGen Gallery specific uploader works as expected, no error upon uploading. No other problem noticed for the moment.

@herrvigg
Copy link
Collaborator

Great. I want to arrange a few things before releasing a fix as 3.14.2 that I want independent from the rolling updates in master that cover many other topics. I'll you know when it's up.

@herrvigg
Copy link
Collaborator

Fix released in 3.14.2 with other improvements for Ajax requests.

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 good first issue Good for newcomers plugin: others Concerns integration with other plugins severity: critical Critical functionality
Projects
None yet
Development

No branches or pull requests

2 participants