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

Prevent duplicate post format taxonomy queries #66627

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

carolinan
Copy link
Contributor

@carolinan carolinan commented Oct 31, 2024

What?

If Gutenberg is active on WordPress 6.7 or later, the filter that adds the post format to the taxonomy query should not run twice.
This PR adds an early return to gutenberg_add_format_query_vars_to_query_loop_block if the post format is already in the taxonomy query.

Closes #66071

Testing Instructions

I tested this by doing the following:

First I activated Gutenberg with this PR on WordPress 6.7 nightly.
I created a post with a post format and set the query loop to show this format.
Then I edited gutenberg_add_format_query_vars_to_query_loop_block and added a temporary echo inside the new if-statement, to confirm that the early return was triggered on the front of the website.
I also confirmed that the correct post was still shown.

Then I ran the Gutenberg PHP tests without issues. I have not ran the core tests!

Then I activated Gutenberg with the PR on WordPress 6.6.2 and re-did the manual test of the query loop with the post format filter applied, and confirmed that the filter still worked.

Add an early return to gutenberg_add_format_query_vars_to_query_loop_block if the taxonomy query already includes post formats.
@carolinan carolinan added [Type] Bug An existing feature does not function as intended No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Block] Query Loop Affects the Query Loop Block labels Oct 31, 2024
@carolinan carolinan marked this pull request as ready for review October 31, 2024 06:24
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: carolinan <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: david-binda <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@carolinan carolinan requested a review from Mamaduka October 31, 2024 06:24
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up, @carolinan!

@carolinan carolinan merged commit 99d2275 into trunk Nov 1, 2024
79 of 81 checks passed
@carolinan carolinan deleted the fix/duplicate-query-vars-filter branch November 1, 2024 04:42
@github-actions github-actions bot added this to the Gutenberg 19.7 milestone Nov 1, 2024
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
Add an early return to gutenberg_add_format_query_vars_to_query_loop_block if the taxonomy query already includes post formats. 

Co-authored-by: carolinan <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: david-binda <[email protected]>
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 No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate post format taxonomy query in Gutenberg 19.4.0 when run on WordPress 6.7 beta
2 participants