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

Infinite Scroll: No longer treated as an ajax request #15837

Closed
WPprodigy opened this issue May 19, 2020 · 2 comments · Fixed by #15843
Closed

Infinite Scroll: No longer treated as an ajax request #15837

WPprodigy opened this issue May 19, 2020 · 2 comments · Fixed by #15843
Labels
[Feature] Infinite Scroll [Type] Bug When a feature is broken and / or not performing as intended

Comments

@WPprodigy
Copy link
Contributor

WPprodigy commented May 19, 2020

Infinite Scroll requests are no longer being treated as ajax requests, causing various pre_get_post filters to incorrectly alter the query - breaking things pretty bad in some cases.

IS doesn't use a traditional WP ajax flow (unsure why?), but attempts to tell WP it is an ajax request here: https://github.com/Automattic/jetpack/blob/master/modules/infinite-scroll/infinity.php#L1725

However, with the latest changes to IS (presumably the jQuery removal), this no longer happens because HTTP_X_REQUESTED_WITH is never set.

Replicated with JP version 8.5 and 8.4.2. Does not happen in 8.3.

One solution is to alter the PHP side and just see if the request method is POST (cleanest option?). Otherwise can continue passing XMLHTTPREQUEST like jQuery.ajax does around here: https://github.com/Automattic/jetpack/blob/master/modules/infinite-scroll/infinity.js#L353 (probably best for BC?)

@WPprodigy WPprodigy added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Infinite Scroll labels May 19, 2020
@jeherve
Copy link
Member

jeherve commented May 19, 2020

cc @dero who worked on the Infinite Scroll changes in #15017

@dero
Copy link
Contributor

dero commented May 19, 2020

@WPprodigy @jeherve Thanks for bringing this to my attention, it's clearly a regression. Created a PR that ensures the X- header is sent along with the AJAX request even in vanilla JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Infinite Scroll [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants