Member Content: Courses: Improve SQL query for 6.9 compat. #957
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Testing in 6.9 RC1 raised a SQL error when using Member Content and modifying the
get_adjacent_post()query to determine the previous/next page links within a course (series of WordPress pages gated by form, tag or product):This is due to a change in the original query, before modification:
WHERE p.post_date < '2025-11-13 14:07:58' AND p.post_type = 'page' AND ( p.post_status = 'publish' OR p.post_status = 'private' )WHERE (p.post_date < '2025-11-13 14:04:15' OR (p.post_date = '2025-11-13 14:04:15' AND p.ID < 3)) AND p.post_type = 'page' AND ( p.post_status = 'publish' OR p.post_status = 'private' )The replacement WHERE clause was too generic in replacing part of the query on the first AND.
This PR resolves by using a more specific search and replace, and submitted here to backport test against 6.8.
Testing
Existing tests pass.
Checklist