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

13.2 breaks Query Loop taxonomy filters (on front end) #41067

Closed
andrewstaffell opened this issue May 14, 2022 · 29 comments
Closed

13.2 breaks Query Loop taxonomy filters (on front end) #41067

andrewstaffell opened this issue May 14, 2022 · 29 comments
Labels
[Block] Query Loop Affects the Query Loop Block Needs Testing Needs further testing to be confirmed. [Type] Regression Related to a regression in the latest release

Comments

@andrewstaffell
Copy link

andrewstaffell commented May 14, 2022

Description

Between 13.1 and 13.2 the category / tag / taxonomy filters for Query Loop stop having an effect on the front end. I tried to see what was causing it in the diff but can't work it out. However, I added logging to a function hooked to pre_get_posts and it is not being called at all in 13.2. Verified in both local and server environments.

The issue doesn't affect the editor. Just front end.

Step-by-step reproduction instructions

  1. Install Gutenberg 13.1.
  2. Set up a Query Loop block and choose a Category from Filters in the block sidebar.
  3. Verify that on front end the Category filter is being applied correctly.
  4. Update Gutenberg to 13.2.
  5. Check same page. Filters no longer apply. Query Loop just shows all posts chronologically.

Screenshots, screen recording, code snippet

Before (13.1)

Screenshot 2022-05-14 at 09 11 05

After (13.2)

Screenshot 2022-05-14 at 09 12 43

Environment info

WP 5.9, Gutenberg 13.2 (but not 13.1)

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

@andrewstaffell andrewstaffell changed the title Query Loop taxonomy filter breaks on front end in 13.2 Query Loop breaks taxonomy filter on front end in 13.2 May 14, 2022
@andrewstaffell andrewstaffell changed the title Query Loop breaks taxonomy filter on front end in 13.2 13.2 breaks Query Loop taxonomy filters (on front end) May 14, 2022
@skorasaurus skorasaurus added [Type] Regression Related to a regression in the latest release [Block] Query Loop Affects the Query Loop Block labels May 14, 2022
@poof86
Copy link

poof86 commented May 16, 2022

I can confirm that category filters do not work front-end in version 13.2
Is there a quick fix I can apply without going back to 13.1?

@Diachrony
Copy link

Also can confirm this issue. Would love a fix or work-around asap as my site is completely broken without this functionality.

@ntsekouras
Copy link
Contributor

ntsekouras commented May 18, 2022

If you create a new Query Loop filter with category filters in 13.2, does it work for you? For me it does, but will investigate more.


--edit

I just tried having a Query Loop from 13.1 and then in 13.2, everything seemed to worked fine as well. 🤔

Can you share more info about your setup or more details in general?

@ntsekouras ntsekouras added the Needs Testing Needs further testing to be confirmed. label May 18, 2022
@andrewstaffell
Copy link
Author

andrewstaffell commented May 18, 2022

@ntsekouras: The filters work fine in the block editor, but have stopped working on the front-end (where I understand they are using gutenberg_build_query_vars_from_query_block() via gutenberg_render_block_core_post_template() although I can't see any changes to those in the 13.2 diff).
Nothing special about the setup, it arose in a project with custom theme + plugins but then I tested with Twenty Twenty Two and no plugins (WP 5.9.3).
Multiple people reporting the same issue and it's just been reported in the Calypso repo too.

@Diachrony
Copy link

@ntsekouras I have a fairly simple, non-custom set-up using the block editor on Twenty Twenty-Two. I have tried creating a new post draft with a standard query and it also fails to do any requested filtering in the preview (like other 3 other published pages I have that use queries), however the editing page shows the expected proper filtering.
WordPress version 5.9.3
Current theme: Twenty Twenty-Two (version 1.0.1-wpcom)
Forminator (version 1.15.12)
PHP version 7.4.29

@ntsekouras
Copy link
Contributor

The filters work fine in the block editor, but have stopped working on the front-end

I know, I tested that.

@andrewstaffell and @Diachrony do you experience the problem through Calypso? Because you both mention it. I'm testing with core.

@Diachrony
Copy link

Diachrony commented May 18, 2022

@ntsekouras I'm sorry. I'm not sure about Calypso. Where can I look to find whether it is being used. It is not anything I intentionally installed but may be there by default?

edit: it may have been @alliebbush2 that mentioned it above?

@andrewstaffell
Copy link
Author

@ntsekouras I'm using Core too. WP 5.9.3.

@poof86
Copy link

poof86 commented May 18, 2022

Wordpress.org 5.9.3 on server here with Gutenberg installed and updated from Wordpress plugin page

@ntsekouras
Copy link
Contributor

I mean if your sites are in WordPress.com. If yes they will be using Calypso.

@Diachrony your mention was implicit through:

Current theme: Twenty Twenty-Two (version 1.0.1-wpcom)

@andrewstaffell
Copy link
Author

@ntsekouras I'm using .org. Bug reproduced locally and in server environment.

@youknowriad
Copy link
Contributor

I'm following the instructions above, and I was not able to reproduce either 🤔 There must be another parameter in the equation.

@Diachrony
Copy link

image

Plugins and their versions if that helps. Let me know if you can think of any other info that I can grab for you and I'll send what I can tomorrow. Really appreciate your work on this!

@ntsekouras
Copy link
Contributor

Thanks for all the info @Diachrony! I could reproduce in .com (that's your case), but we are trying to reproduce in core.

@andrewstaffell
Copy link
Author

andrewstaffell commented May 18, 2022

@youknowriad I completely removed and redid the block with 13.2.1 installed and it now seems to be working OK here. I need to test this out on the production environment where the bug first arose, but in the meantime I wanted to share something I've spotted in the source code of one of the intermediate revisions, which is that both category and categoryIDs were set in the attributes at some point:

<!-- wp:query {"queryId":44,"query":{"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"perPage":8,"taxQuery":{"category":[16]},"categoryIds":[16]},"displayLayout":{"type":"list"},"align":"wide"} -->

I think one of these is an older format but it's strange they were both showing up in the same revision? Possible issue with block migration code?

@youknowriad
Copy link
Contributor

youknowriad commented May 18, 2022

I think one of these is an older format but it's strange they were both showing up in the same revision? Possible issue with block migration code?

Yes, that's a possibility, it would be good to have the "old" markup (before the upgrade) that failed to try with.

@andrewstaffell
Copy link
Author

andrewstaffell commented May 18, 2022

Still failing for me in production in 13.2.0 or 13.2.1 (but fine in 13.1). Example markup that's failing:

<!-- wp:query {"queryId":2,"query":{"perPage":2,"pages":0,"offset":"0","postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false,"taxQuery":{"category":[6]}},"displayLayout":{"type":"flex","columns":2},"align":"full","className":"is-style-default","layout":{"contentSize":"70rem"}} -->

@chad1008
Copy link
Contributor

chad1008 commented May 18, 2022

I've been testing this today both locally and on WordPress.com and I'm also not able to reproduce. Clearly there's something going on, but there's some obscure variable preventing some of us from seeing it.

Even copypastaing @andrewstaffell's provided markup renders as expected for me! Not sure what's triggering it for some sites/users but not others 🤔

Tested with Chrome 101.0.4951.64. Unable to reproduce on either a WordPress.com site, or locally running WordPress 5.9.3 and Gutenberg 13.0, 13.1, or 13.2.1

@chad1008
Copy link
Contributor

I won't repeat the full comment from the other issue, but I do find myself wondering if there might be a link between this issue and #41135. They seem to have a lot in common 🤔

@Diachrony
Copy link

Diachrony commented May 18, 2022

@chad1008

wondering if there might be a link between this issue and #41135.

I don't normally show "Author name" on my posts, but I just added into a test query and you are correct. The author name does not seem to show in the preview page
image

@andrewstaffell
Copy link
Author

andrewstaffell commented May 18, 2022 via email

@ironprogrammer
Copy link
Contributor

Reproduction Report

Environment

  • OS: macOS 12.3.1
  • Web Server: Nginx
  • PHP: 7.4.29
  • WordPress: 5.9.3 (tested with clean install and after wp db reset on a pre-existing install)
  • Browser: Safari 15.4, Google Chrome 101.0.4951.64
  • Theme: Twenty Twenty-Two, Twenty Twenty-One
  • Active Plugins:
    • Gutenberg 13.1.0, 13.2.0, 13.2.1

Steps to Reproduce

  1. Prerequisites: Install/enable Gutenberg 13.1.0. Create at least two categories, and then multiple posts using one of those categories. This is required to filter the Query Loop block. (E.g. wp post generate --count=10 is helpful toward this.)
  2. Create a new post and add a Query Loop block. Click the Choose button and accept the default loop template.
  3. In the block sidebar, under Filters in the Categories box, type and select one of the categories created in Step 1. You may need to re-select the Query Loop wrapping block, such as through the List View sidebar (Ctrl-Opt-O on macOS).
  4. After category selection, the backend editor will refresh and display the filtered results.
  5. Publish post, and open frontend page in a new tab/window.
  6. Observe that the query displays posts filtered by the chosen category.
  7. Upgrade Gutenberg to 13.2.0 (or 13.2.1). (E.g wp plugin update gutenberg --version=13.2.0.)
  8. Refresh the frontend page.
  9. 🐛 Observe that the posts are no longer filtered by category.

Reproduction Results

Screenshots (from TT2)

*Note that even-numbered posts have test filter applied.


Gutenberg 13.1.0

Gutenberg 13.2.0

@andrewstaffell
Copy link
Author

andrewstaffell commented May 19, 2022

Apparently fixed by #41122 (not yet tested by me, but according to #41135)

@ironprogrammer
Copy link
Contributor

Just confirming here for additional consensus 👍🏻

After testing gutenberg:trunk following PR 41122 merge, this has resolved the reported issue.

Test Report

Patch: #41122

Environment

Steps to Test Patch

  • Prerequisites: Install/enable Gutenberg 13.2.1. Create at least two categories, and then multiple posts using one of those categories. This is required to filter the Query Loop block. (E.g. wp post generate --count=10 is helpful toward this.)
  • Create a new post and add a Query Loop block. Click the Choose button and accept the default loop template.
  • In the block sidebar, under Filters in the Categories box, type and select one of the categories created in Step 1. You may need to re-select the Query Loop wrapping block, such as through the List View sidebar (Ctrl-Opt-O on macOS).
  • After category selection, the backend editor will refresh and display the filtered results.
  • Publish post, and open frontend page in a new tab/window.
  • Observe that the query displays posts filtered by the chosen category.
  • 🛠 Apply patch / upgrade Gutenberg to trunk.
  • Refresh the frontend page.
  • ✅ Observe that the posts remain filtered by category.

Test Results

✅ Patch addresses reported issue.

Screenshots

Screenshot of test result

Gutenberg `trunk`

@Mamaduka
Copy link
Member

The issue should be fixed with Gutenberg 13.2.2. See the details - #41135 (comment).

@slaFFik
Copy link

slaFFik commented Jul 30, 2022

I'm not sure what has been fixed (so many seemingly unrelated issues are linked in the thread), but I get exactly the same problem as OP shared in initial issue description in both clean WordPress 6.0.1 and Gutenberg 13.7.3 with FrostWP theme.

See screenshot.
On the left - Block Editor (GB 13.7.3)
On the right - front-end (FrostWP)
image

So filtering by category for a CPT created using Pods plugin works fine inside the Block Editor, but not working on the front-end.

@FlorientR
Copy link

I'm not sure what has been fixed (so many seemingly unrelated issues are linked in the thread), but I get exactly the same problem as OP shared in initial issue description in both clean WordPress 6.0.1 and Gutenberg 13.7.3 with FrostWP theme.

See screenshot. On the left - Block Editor (GB 13.7.3) On the right - front-end (FrostWP) image

So filtering by category for a CPT created using Pods plugin works fine inside the Block Editor, but not working on the front-end.

Hi !

After search on code, the taxonomy must be "publicly_queryable" for work on front.

Bye !

@slingshotdesign
Copy link

@FlorientR thank you!

@marcizus
Copy link

@FlorientR thank you. Your answer helped me.

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 Needs Testing Needs further testing to be confirmed. [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests