[wp-trac] [WordPress Trac] #64390: get_adjacent_post() SQL changes can loop infinitely in Storefront/derivative theme code
WordPress Trac
noreply at wordpress.org
Tue Dec 9 22:47:01 UTC 2025
#64390: get_adjacent_post() SQL changes can loop infinitely in
Storefront/derivative theme code
-------------------------------+------------------------------------
Reporter: jmdodd | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 6.9
Severity: normal | Resolution:
Keywords: | Focuses: template, performance
-------------------------------+------------------------------------
Changes (by westonruter):
* focuses: performance => template, performance
* component: General => Posts, Post Types
Old description:
> This is mostly for informational purposes. The SQL changes in
> https://core.trac.wordpress.org/changeset/61066 caused an infinite loop
> in a number of WooCommerce themes (Storefront and its derivatives, among
> others) that were relying on the existing behavior to handle adjacent
> product links. I don't think this was a predictable outcome, but is one
> that should be considered going forward when publishing Field Guides and
> making SQL changes to core.
>
> The affected themes used a filter on get_{$adjacent}_post_where to
> advance the product search past the date (using < or > comparators) of a
> currently found-but-hidden adjacent product, ensuring that the search can
> continue down the chain of posts. When the SQL change was made, it became
> possible to find an invalid (hidden) post with the **same** date as the
> current global $post. Because the date was no longer a reliable barrier
> to selecting the same invalid post, each attempt to find a previous
> product substituted the same date that was already present in the query,
> running the same search while never advancing any further. When combined
> with Storefront's lack of any looping protections, this lead to an
> infinite loop on certain product pages where the next product down the
> line had the same timestamp as the current product and was a hidden
> product.
>
> Storefront has been updated in
> https://github.com/woocommerce/storefront/pull/2202, but many of the
> derivative themes may not be aware of the issue.
>
> To reproduce, products in the same category should have the same
> post_date, and one should have Catalog visibility: Hidden set. Visiting a
> product page adjacent to the hidden one will cause this loop.
>
> Related reports:
> -
> https://www.reddit.com/r/Wordpress/comments/1pd35y4/wordpress_69_is_causing_permanent_100_cpu_usage/
> - https://github.com/woocommerce/woocommerce/issues/62233
New description:
This is mostly for informational purposes. The SQL changes in [61066] for
#8107 caused an infinite loop in a number of WooCommerce themes
(Storefront and its derivatives, among others) that were relying on the
existing behavior to handle adjacent product links. I don't think this was
a predictable outcome, but is one that should be considered going forward
when publishing Field Guides and making SQL changes to core.
The affected themes used a filter on `get_{$adjacent}_post_where` to
advance the product search past the date (using < or > comparators) of a
currently found-but-hidden adjacent product, ensuring that the search can
continue down the chain of posts. When the SQL change was made, it became
possible to find an invalid (hidden) post with the **same** date as the
current global `$post`. Because the date was no longer a reliable barrier
to selecting the same invalid post, each attempt to find a previous
product substituted the same date that was already present in the query,
running the same search while never advancing any further. When combined
with Storefront's lack of any looping protections, this lead to an
infinite loop on certain product pages where the next product down the
line had the same timestamp as the current product and was a hidden
product.
Storefront has been updated in
https://github.com/woocommerce/storefront/pull/2202, but many of the
derivative themes may not be aware of the issue.
To reproduce, products in the same category should have the same
`post_date`, and one should have Catalog `visibility: hidden` set.
Visiting a product page adjacent to the hidden one will cause this loop.
Related reports:
-
https://www.reddit.com/r/Wordpress/comments/1pd35y4/wordpress_69_is_causing_permanent_100_cpu_usage/
- https://github.com/woocommerce/woocommerce/issues/62233
--
Comment:
cc @ramonopoly
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64390#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list