WordPress / wordcamp.org

WordCamps are casual, locally-organized conferences covering everything related to WordPress.
https://wordcamp.org
127 stars 69 forks source link

Query loop not working with more than 3 results or changing results number in the block #1220

Closed CarlosLongarela closed 7 months ago

CarlosLongarela commented 7 months ago

Query loop block it's not working if we change the number of results to show because saves as string and only works as string.

This happens in the WordCamp multisite. Checked in another multisite non-WordCamp and working fine.

To reproduce

Steps to reproduce the behaviour:

  1. Go to a WordCamp website.
  2. Create a new page.
  3. Insert a Query Loop Block.
  4. Change the number of Item Per Page to 4
  5. Results will say “No results found.”
  6. See error

We have the problem with our staging website https://wceutest24.wordcamp.org/2024/ and also live website https://europe.wordcamp.org/2024/

A recorded a video with several tests and the bug: https://video.tabernawp.com/conversations/fa2cdc82-7f9a-570d-9769-b2e351641649

ryelle commented 7 months ago

How strange— it looks like changing the "items per page" value is also changing the offset — I tried this on a WC site and saw API requests like this:

Increasing the offset just added to it:

Off the top of my head, I don't know what could be interfering there.

CarlosLongarela commented 7 months ago

Yes, it's very strange. I made a test in another multisite (that it isn't a WordCamp multisite) and the Query Loop works without any problem (and works with the number as integer and as string).

pkevan commented 7 months ago

I'd imagine it's some filtering pre_get_posts for something else, since the offset always seems to be 40 plus the offset from the query loop block.

ryelle commented 7 months ago

since the offset always seems to be 40 plus the offset from the query loop block.

In my testing, the offset was per_page * 10 + offset — when I set it to 2 per page, it's offset=20, 3 -> offset=30, and so on.

The strange part to me is that the API request is what's changed, so the API response is correct (to what it's asked for) but somewhere in the "fetch posts" logic it's changing the query.

ryelle commented 7 months ago

Oh, it's not math but concatenation — perPage + offset. It looks like this was an issue in Gutenberg (https://github.com/WordPress/gutenberg/issues/56439), and should have been fixed in 17.2, but WordCamp.org is still on 17.1.2. Updating GB should fix the issue.

CarlosLongarela commented 7 months ago

Oh, fantastic news, but WordCamp.org could be updated to 17.2? or we have any solution to this to finish our team design and go live?

pkevan commented 7 months ago

Gutenberg has been updated to 17.5.1, which resolves the issue.

iandunn commented 7 months ago

It looks like that upgrade broke the query-filter block on events.w.org, see #1225 for details

adamwoodnz commented 7 months ago

Unfortunately we've had to temporarily roll back Gutenberg to 17.1.4 to fix the above issue with the Events homepage query filters, so this issue will be present again. We plan to ship another fix asap. Sorry for any inconvenience caused.

ryelle commented 7 months ago

The WordCamp network has been updated to Gutenberg 17.6, so this should be fixed again.