Problem/Motivation

Fatal error occur when trying to check access on a coupon which is not attached to a promotion.

Proposed resolution

Check coupon has promotion before using the access method of this promotion.

Comments

GoZ created an issue. See original summary.

GoZ’s picture

Status: Active » Needs review
bojanz’s picture

Status: Needs review » Needs work

On the PR Matt commented how it might make sense to explicitly deny access if the parent promotion is missing.
The 1 difference between "neutral" and "forbidden" is whether administrators can still update/delete such broken promotions.
I think it makes sense to keep that for now (neutral -> admin can still update/delete).

However, we need to change the code to use $result->orIf().

bojanz’s picture

Title: Coupon access should not break if coupon is not attached to a promotion » Rework CouponAccessControlHandler

Giving this a wider title, since we want to add a few more things:

1) Documentation to the handler that shows the logic
2) Stop calling the parent, add the admin permission logic directly.
3) Add a test.

  • bojanz committed ff07d9d on 8.x-2.x
    Issue #2947227 by GoZ, bojanz: Rework CouponAccessControlHandler
    
bojanz’s picture

Status: Needs work » Fixed

Here's the forgotten commit. Added docs, tests, inlined the admin permission check, added a forbidden result for the malformed entity as Matt suggested.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.