Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
GoZ CreditAttribution: GoZ at Iosan, Barbe-Rousse for Niji commentedsee https://github.com/drupalcommerce/commerce/pull/850
Comment #3
bojanz CreditAttribution: bojanz at Centarro commentedOn 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().
Comment #4
bojanz CreditAttribution: bojanz at Centarro commentedGiving 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.
Comment #6
bojanz CreditAttribution: bojanz at Centarro commentedHere's the forgotten commit. Added docs, tests, inlined the admin permission check, added a forbidden result for the malformed entity as Matt suggested.