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

Query loop infinite loop when inheriting query from template #43198

Closed
ebinnion opened this issue Aug 12, 2022 · 2 comments · Fixed by #43221
Closed

Query loop infinite loop when inheriting query from template #43198

ebinnion opened this issue Aug 12, 2022 · 2 comments · Fixed by #43221
Assignees
Labels
[Block] Query Loop Affects the Query Loop Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@ebinnion
Copy link

Description

This originally presented as a bug on WordPress.com where pages would not load at all in some occasions and was reported here:

Automattic/wp-calypso#66270

High-level, the issue is that in #40656 we changed how we handled the inherit query from template logic. Instead of pulling args out of the template query and then creating a new query object. We actually began to use the template query.

When we then call have_posts and hit the end of the loop within the block rendering, this resets the query while we're still in the block, and we're never able to pass the have_posts check in the template.

Step-by-step reproduction instructions

See Automattic/wp-calypso#66270 (comment)

Screenshots, screen recording, code snippet

No response

Environment info

  • Tested against most recent 13.8.1 as well as 13.8.0
  • Presents in WordPress.com and self-hosted sites.
  • Presents when using the Gutenberg plugin combined with a non site editor theme, such as TwentyTwentyOne

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@priethor priethor added [Type] Bug An existing feature does not function as intended [Block] Query Loop Affects the Query Loop Block [Priority] High Used to indicate top priority items that need quick attention labels Aug 12, 2022
@priethor
Copy link
Contributor

I can consistently reproduce the issue in a self-hosted site with WordPress 6.0.1, Gutenberg 13.8.2, and different classic themes.

@priethor
Copy link
Contributor

I'm leaving myself a reminder to add the Backport to WP minor release label to future PRs that solve this issue. ✍️

@draganescu draganescu self-assigned this Aug 15, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Aug 15, 2022
Repository owner moved this from Triage to Done in WordPress 6.0.x Editor Tasks Aug 19, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Sep 2, 2022
felixarntz added a commit that referenced this issue Aug 28, 2023
draganescu pushed a commit that referenced this issue Aug 29, 2023
…ng problematic workaround (#49904)

* Use global main query directly so that global query loop works as expected.

* Remove hack to enforce query loop as it causes problems, and the loop needs to be handled in block templates instead.

* Maintain fix from #43198.

* Clarify logic with comment.

* Add test coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants