Open dominiquemariano opened 8 months ago
@ideadude Digging into this, the actual behavior should likely be to have three webhooks fired (once for each course), plus potentially another webhook for [ student_id, membership_id ]
.
An attempt is being made to queue up a webhook for delivery for each course, but LLMS_REST_Webhook::should_deliver()
is returning false
for the second and third courses. This is because when an attempt to queue the webhook is made, the first argument is added to the processed
array (in this case, the student ID). is_already_processed()
then returns true
for the second and third hooks, with [ student_id, course_id ]
as the arguments, and are rejected.
We could make this smarter by looking at all of the arguments to decide if it's already been enqueued instead of just the first one, depending on the resource and event of a particular webhook. The current "is already processed" check could also be causing some random uniqueness issues, ie. a webhook is enqueued for the first argument of a student (user) id of 5
when a different webhook is attempted with the first argument of 5
but for a different type of object.
Reproduction Steps
Membership 1
.Course 1
,Course 2
, andCourse 3
.Membership 1
in the backend and addCourse 1
,Course 2
, andCourse 3
toMembership Settings > Auto Enrollment
.Membership 1
.WordPress Dashboard > LifterLMS > Settings > REST API > Webhooks
and setTopic
toEnrollment created
.Delivery URL
and to view the payload.WordPress Dashboard > Users > Add New
.Membership 1
while logged in as that student.Expected Behavior
The payload should contain information about
Course 1
,Course 2
, andCourse 3
.Actual Behavior
The payload contains information about
Course 1
.This issue has be recreated: