[wp-trac] [WordPress Trac] #26937: get_adjacent_post() should use WP_Query rather than build its own SQL query
WordPress Trac
noreply at wordpress.org
Fri Mar 28 23:03:51 UTC 2014
#26937: get_adjacent_post() should use WP_Query rather than build its own SQL query
-------------------------+-----------------------
Reporter: ethitter | Owner: nacin
Type: enhancement | Status: reopened
Priority: normal | Milestone: 3.9
Component: Query | Version: 3.7
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+-----------------------
Comment (by ethitter):
Replying to [comment:49 kovshenin]:
> Nacin is right. It does indeed split the query with external object
cache so my patch is pretty useless. However, after a little more
debugging it turned out that string replacement in alias_posts_table()
breaks the `"$wpdb->posts.*" == $fields` assumption in WP_Query, thus
explicitly setting $split_the_query to false :(
Overcoming this is a matter of using the `split_the_query` filter to set
the value, instead of passing it via the query arguments. Easy enough, it
would seem.
Unfortunately, when the query is split, the string manipulation in
`alias_posts_table()` results in invalid SQL, because `WP_Query` expects
the posts table to be in the SQL as whatever `$wpdb->posts` is. The answer
is to reverse the string manipulation after the legacy filters are
applied. I am a bit concerned with the amount of string manipulation this
requires, but on the upside, the manipulations are rather basic.
I'm working on a new patch.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26937#comment:50>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list