Fix media library grid pagination for non-admin users#1679
Open
dd32 wants to merge 6 commits into
Open
Conversation
The previous the_posts filter removed payment attachments from query results after the query ran, which caused the media library grid to stop loading more items for non-admin users. The JavaScript checks if the returned batch size is less than posts_per_page to determine if there are more items, so removing items post-query broke pagination. Switch to posts_clauses to exclude other users payment attachments at the SQL level, keeping found_posts and results consistent. Fixes WordPress#1316 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
Replace the two IN (SELECT ...) subqueries with a single LEFT JOIN on the parent post, making the SQL more readable and efficient. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9234f40 to
8b6fb99
Compare
Tests that admins see all attachments, editors see their own payment attachments, editors see attachments on their own payment posts, and unrelated editors cannot see other users payment attachments. Also verifies found_posts matches actual results (the original bug). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In multisite, manage_options requires super admin status rather than just the administrator role with add_cap. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
the_postsfilter inprivacy.phpremoved payment file attachments AFTER the query, causing fewer results thanposts_per_page. The JavaScript then concluded there were no more items to load.the_poststoposts_clauses, so the exclusion happens at the SQL level andfound_postsmatches the actual resultsFixes #1316
Test plan
🤖 Generated with Claude Code