I believe this is a bug and the priority should probably be higher, but since I'm still trying to figure out what's going on, I tried to be conservative and contain my panic.
I ppgraded a site using Commerce 1.8 to to 1.9 yesterday. Thought everything was working fine on the Dev site when I was logged in as User 1, and then upgraded the production site before logging in as a regular admin user. My bad, I know!
Anyway, I discovered that the regular commerce admins for the site now only see their own orders when the go to the View admin/commerce/orders.
Inspection of the SQL for this view shows that when logged in as User 1 the Orders View produces this SQL:
SELECT commerce_order.order_id AS order_id, commerce_order.order_number AS commerce_order_order_number, commerce_order.uid AS commerce_order_uid, commerce_order.created AS commerce_order_created, commerce_customer_profile_field_data_commerce_customer_billing.profile_id AS commerce_customer_profile_field_data_commerce_customer_billi, users_commerce_order.name AS users_commerce_order_name, users_commerce_order.uid AS users_commerce_order_uid, commerce_order.status AS commerce_order_status, 'commerce_customer_profile' AS field_data_commerce_customer_address_commerce_customer_profi, 'commerce_order' AS field_data_commerce_order_total_commerce_order_entity_type
FROM
{commerce_order} commerce_order
LEFT JOIN {users} users_commerce_order ON commerce_order.uid = users_commerce_order.uid
LEFT JOIN {field_data_commerce_customer_billing} field_data_commerce_customer_billing ON commerce_order.order_id = field_data_commerce_customer_billing.entity_id AND (field_data_commerce_customer_billing.entity_type = 'commerce_order' AND field_data_commerce_customer_billing.deleted = '0')
LEFT JOIN {commerce_customer_profile} commerce_customer_profile_field_data_commerce_customer_billing ON field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing.profile_id
WHERE (( (commerce_order.status IN ('canceled', 'pending', 'processing', 'completed')) ))
ORDER BY commerce_order_created DESC
LIMIT 50 OFFSET 0but when logged in as the site's commerce admin in charge of manageing orders the SQL from the view is:
SELECT commerce_order.order_id AS order_id, commerce_order.order_number AS commerce_order_order_number, commerce_order.uid AS commerce_order_uid, commerce_order.created AS commerce_order_created, commerce_customer_profile_field_data_commerce_customer_billing.profile_id AS commerce_customer_profile_field_data_commerce_customer_billi, users_commerce_order.name AS users_commerce_order_name, users_commerce_order.uid AS users_commerce_order_uid, commerce_order.status AS commerce_order_status, 'commerce_customer_profile' AS field_data_commerce_customer_address_commerce_customer_profi, 'commerce_order' AS field_data_commerce_order_total_commerce_order_entity_type
FROM
{commerce_order} commerce_order
LEFT JOIN {users} users_commerce_order ON commerce_order.uid = users_commerce_order.uid
LEFT JOIN {field_data_commerce_customer_billing} field_data_commerce_customer_billing ON commerce_order.order_id = field_data_commerce_customer_billing.entity_id AND (field_data_commerce_customer_billing.entity_type = 'commerce_order' AND field_data_commerce_customer_billing.deleted = '0')
LEFT JOIN {commerce_customer_profile} commerce_customer_profile_field_data_commerce_customer_billing ON field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing.profile_id
WHERE (( (commerce_order.status IN ('canceled', 'pending', 'processing', 'completed')) ))AND(( (commerce_customer_profile_field_data_commerce_customer_billing.type = 'billing') AND (commerce_customer_profile_field_data_commerce_customer_billing.uid = '11624') )OR (commerce_customer_profile_field_data_commerce_customer_billing.uid = '11624') )
ORDER BY commerce_order_created DESC
LIMIT 50 OFFSET 0Note the difference in the last WHERE Clause with filtering by UID. 11624 is of course the uid of the logged in order admin.
I have of course inspected all the user permissions and nothing has changed there. I don't understand why this extra filter is being added or how.
Thanks for your help in advance! Any ideas that anyone might have for me to correct this would be greatlly appreciated.
Steve
Comments
Comment #1
rszrama commentedHave you checked your permissions to ensure those administrators actually have permission to view any order of any type? Only if they didn't would I expect them to be getting those uid specific conditions.
Comment #2
wickwood commentedYes, checked and doubled checked both the permissions table and their roles.
These admins have the folowing permissions:
I'll do some more exploring of this this issue to night and if I find anything, I'll be sure to let you know.
Thanks Again!
Steve
Comment #3
wickwood commentedIf I turn off
Disable SQL rewritingin theViews > Advanced > Other > Query Settings, then things work as they should.But I have no idea of where the additional node_access checks are being introduced.
Any ideas on how I can track this down? I tried Devel Node Access, but those blocks are showing up in the view page.
Thanks again for any assistance in advance. If I have to, I'll just
Disable SQL rewriting, but I would rather no things are work correctly rather than turn this on.Steve
Comment #4
rszrama commentedYou can leave it disabled and ensure the View's access control and filters restrict access to the View and its contents as necessary - or you can enable the appropriate permissions for customer profiles. I missed that that's what the uid check was on. : )
Comment #5
wickwood commentedThanks Rszrama for confirming for me that that I did the right thing, but I don't understand by what you mean by "you can enable the appropriate permissions for customer profiles". Is this something new in Drupal Commerce 7.x-1.9?
Things have been working for me for months until this update. Admittedly though I can't be sure it's not due to some other module's update, but still it sounds like I need to understand what the "appropriate permissions for customer profiles" are.
I would appreciate it if you can point me in the right direction!
Thanks again,
Steve
Comment #6
rszrama commentedPreviously we weren't very intelligently determining the base table in our entity access query altering, so it's likely that when your View was attempting to determine access to view a customer profile it was seeing access to the order instead. Not entirely sure. In any event, granting the permission for them to view customer profiles should work, or, if you don't want them having full permission to view customer profiles, disabling SQL rewriting would be appropriate assuming you had other filtering in place to ensure the results in the View were only meant to be seen by the user accessing the View.