For shop administrators (non site admins) the order status column is empty on the view orders page (admin/store/orders/view).

This is because Views require a field to have an AccessResult::allowed() to show it. The access() method is not implemented yet for the uc_order_status entity type. Implementing it solves the problem.

Please review / commit patch.

Comments

bjaxelsen created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, order_status_access.patch, failed testing.

bjaxelsen’s picture

the failing test (product kit discounts) appears to be unrelated to the patch

The last submitted patch, order_status_access.patch, failed testing.

TR’s picture

Status: Needs work » Needs review
david.czinege’s picture

I tested the uploaded patch. When i wanted to see my order history with an authenticated user, i got a fatal error:

Fatal error: Call to a member function isAllowed() on null in /var/www/drupalvm/drupal/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php on line 58

You can try this if you visit for example te next page:
/user/10/orders

I rewrite the patch, and I added the view own orders permission also.

Please review it.

longwave’s picture

Status: Needs review » Needs work

I think instead we need an OrderStatusAccessControlHandler class that extends EntityAccessControlHandler and performs permission checks for view, create, update and delete.

bjaxelsen’s picture

Updated patch

david.czinege’s picture

Status: Needs work » Needs review
FileSize
2.63 KB

I have created the OrderStatusAccessControlHandler class and set it as access handler for the OrderStatus configuration entity.

david.czinege’s picture

I updated the OrderTest's testOrderCustomerView test case.

Now, in that test case, the order's status is updated to pending, so the user can see the order on the My order history page. I also added a new assertText assertion, which search for the Pending text.

Now i am uploading a patch, which only contains the updated test case, so this patch should fail.

Status: Needs review » Needs work

The last submitted patch, 10: 2770411-order-status-access-10-test-only.patch, failed testing.

david.czinege’s picture

Status: Needs work » Needs review
FileSize
3.52 KB

My previous patch, witch contains only the updated test case, has successfully failed.
Now i upload the a new patch, which contains the updated test case and the bug fix.

This should pass.