#57822 closed defect (bug) (fixed)
Query Loop block showing all posts when Sticky Posts set to "Only"
| Reported by: | RavanH | Owned by: | hellofromTonya |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.2 |
| Component: | Editor | Version: | 5.8 |
| Severity: | normal | Keywords: | has-patch gutenberg-merge has-test-info commit |
| Cc: | Focuses: |
Description (last modified by )
When the Query Loop block has the option "Sticky Posts" set to "Only" and there are NO posts marked as Sticky, the block will show all the latest (non-sticky) posts.
This is related to the VERY old bug #28099 where an empty array passed to 'post__in' is ignored and the query variable is treated as not set.
The bug is set to WONTFIX because fixing it would break too many plugins. It now it affects the Query Loop block.
To reproduce:
- Create a test page with the Query Loop block, set the parameter Sticky Posts to "Only".
- Make sure there are NO posts marked as Sticky.
Expected result: no posts on the test page.
Found result: all latest non-sticky posts on the test page.
This filter will fix the issue:
add_filter( 'query_loop_block_query_vars', function( $query ) {
if ( isset( $query['post__in'] ) && ! $query['post__in'] ) {
$query['post__in'] = [0];
}
return $query;
} );
(since there is no Blocks component (yet?), I've filed this ticket against the Query component)
Attachments (2)
Change History (16)
This ticket was mentioned in โPR #4144 on โWordPress/wordpress-develop by โRavanH.
4 years ago
#1
- Keywords has-patch added
โ@sc0ttkclark commented on โPR #4144:
4 years ago
#2
We ought to add a test for this for query block?
#3
@
4 years ago
- Description modified (diff)
- Version trunk โ 5.8
I noticed that in โGutenberg this case is/was handled but it seems like it was never backported to core?
This ticket was mentioned in โSlack in #core-editor by ocean90. โView the logs.
4 years ago
โ@hellofromTonya commented on โPR #4144:
4 years ago
#5
Commits โhttps://github.com/WordPress/wordpress-develop/pull/4144/commits/526d9b1d853165f539f3bf05a684c063057d856b and โhttps://github.com/WordPress/wordpress-develop/pull/4144/commits/2164f1f199ef8d5b56da0294a8accc5c353fd668 bring full parity with the changes in Gutenberg โhttps://github.com/WordPress/gutenberg/blob/42dad571eac32c41a7ff34f0da80fcc4e5ceb3bd/lib/compat/wordpress-6.1/blocks.php#L171-L183 to synchronize Core and Gutenberg.
#6
@
4 years ago
- Keywords gutenberg-merge added
- Milestone Awaiting Review โ 6.2
- Owner set to
- Status new โ reviewing
Good catch @ocean90!
Marking this ticket as a gutenberg-merge as โPR 4144 synchronizes the changes from Gutenberg into Core.
Self-assigning for commit review.
โ@ntsekouras commented on โPR #4144:
4 years ago
#7
Just for reference, the function โwill be under `6.2` compat folder , since we are including this change now.
So some links for GB in comments would be different.
#8
@
4 years ago
- Component Query โ Editor
Changing the component to Editor as this is bug is related to the Query Loop block, rather than to the Query component.
#9
@
4 years ago
- Keywords has-testing-info added
Testing Instructions
These steps define how to reproduce the issue, and indicate the expected behavior.
Steps to Reproduce
- Add a new Post.
- Add a Query Loop block.
- Select "Start blank".
- Select first layout.
- Change "Sticky Posts" to "Only".
- Publish the post.
- View in the front-end. ๐ Notice all of the non-sticky posts are showing.
Expected Results
When testing a patch to validate it works as expected:
- โ In the front-end, non-sticky posts should not show.
When reproducing a bug:
- โ In the front-end, the non-sticky posts are showing.
Test Report Icons:
๐ <= Indicates where issue ("bug") occurs.
โ <= Behavior is expected.
โ <= Behavior is NOT expected.
#10
@
4 years ago
Test Report
Patch tested: โhttps://github.com/WordPress/wordpress-develop/pull/4144
Environment
- OS: macOS
- WordPress: trunk
- Localhost: wp-env (Docker)
- Plugins: none
- Theme: TT3
- Browser: Chrome
Actual Results
When reproducing a bug/defect:
- โ As trac57822-reproduce-bug-before-patch.gifโ shows, able to reproduce the issue in the front-end.
When testing the bugfix patch:
- โ As trac57822-after-patch.gifโ shows, the patch resolves the issue.
#11
@
4 years ago
- Keywords commit added
Patch: โhttps://github.com/WordPress/wordpress-develop/pull/4144
- Confirmed the changes match โthe changes in Gutenberg โ
- Test Report confirms this patch fixes the reported issue โ
Ready for commit ๐ Prepping it now
โ@hellofromTonya commented on โPR #4144:
4 years ago
#13
Committed via https://core.trac.wordpress.org/changeset/55447.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This fixes the issue where all non-sticky posts show up in the Query Loop block when Sticky Posts is set to "Only" and there are no sticky posts.
Additional
(array)typecast for safety.See https://core.trac.wordpress.org/ticket/57822
Trac ticket: