Wordpress version: 3.1
Rolescoper version: 1.3.28
Setting: Rolescoper -> Features -> Media Libary
Non-editors see other users' attached uploads = TRUE
Non-editors see other users' unattached uploads = TRUE
Users: Administrator, testuser01, testuser02
Testuser01 and Testuser02 are in group: group_role_po
group_role_po has access to the Editor of customposttype PO
All posts are granted to that group
testuser01 and testuser02 are in WordPress defined as: Subscriber
Problem: When a post is created by administrator or by an another user (named: testuser01)
testuser02 cannot edit/view attachments of the post. Where there are normally 4 tabs there are displayed 3 tabs (Upload from PC, Upload from URL, Gallery, Libary)
Gallery is missing from the tabs, but when manually entered the URL in the browser, i just get the window and can modify the attachements without problems.
What i found was de following, the query as administrator is the following: (where 1229 is the post id)
SELECT count(*) FROM wp_posts WHERE post_type = 'attachment'
AND post_status != 'trash' AND post_parent = 1229
But when as Subscriber the query is:
SELECT COUNT( * ) FROM wp_postsWHERE (
(
wp_posts.post_parent =0
)OR (
wp_posts.post_parentIN (
SELECT wp_posts.IDFROM wp_postsWHERE 1 =1AND (
(
wp_posts.post_statusIN (
'future', 'draft', 'pending', 'private', 'publish'
)AND (
(
(
wp_posts.post_type = 'post'AND (
)
)
)OR (
(
wp_posts.post_type = 'page'AND (
)
)
)
)
)
)
)
)
)AND post_type = 'attachment'AND post_status != 'trash'AND post_parent =1229
And as result i get 0
So i tracked down where there is determined that post_parent = 0 and found out it was hard coded (i dont get it, but there is possibly a reason for that)
The place where it gets modified is in file: /hardway/hardway-admin_non-administrator-rs.php
In function: flt_last_resort_query($query)
It is between line: 390 and 423
For some reason, this part:
if ( ! defined('SCOPER_BLOCK_UNATTACHED_UPLOADS') || ! SCOPER_BLOCK_UNATTACHED_UPLOADS )
$unattached_clause = "( $wpdb->posts.post_parent = 0 $author_clause ) OR";
else
$unattached_clause = '';
Always get in the IF part, i couldnt find a situation that caused $unattached_clause = ";
But what goes wrong?
My workaround is before that part of code gets executed i setup: $query_saved = $query; and when the return part is reached (around line 423) i return $query_saved instead of $query, this is how i get it working as my needs.
I tried to understand the SQL query but i cannot explain what it is doing, all i know that both (there is an OR clause) results are 0, so i dont understand what the point is of that part of code.
Is this a bug or a feature? How to deal with this?