Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the API kernel service prior to dispatching the civi.api4.createRequest event when creating an API4 request #21839

Merged
merged 1 commit into from
Oct 16, 2021

Conversation

jensschuppe
Copy link
Contributor

@jensschuppe jensschuppe commented Oct 15, 2021

Overview

Follow-up to #21771 for registering EventSubscriberInterface implementations prior to dispatching the civi.api4.createRequest event.

Before

When issueing an API4 request without having loaded the API kernel service (e.g. invoking the API4 via an Ajax request using CRM.api4()), the civi.api4.createRequest event will not be dispatched with all event subscribers, because the ones registering through an EventSubscriberInterface implementation are only being called when executing the request, as the API kernel service is not being loaded until then.

After

The event is being dispatched with all event subscribers.

Technical Details

This problem only occurs when no other API call has been issued before the API4 call, but API4 explorer fails for entities relying on their EventSubscriberInterface implementation when issueing API4 requests via Ajax.

Comments

This should go into 5.43 along with the original implementation of the civi.api4.createRequest event.

…eRequest` event when creating an API4 request
@civibot
Copy link

civibot bot commented Oct 15, 2021

(Standard links)

@civibot civibot bot added the 5.43 label Oct 15, 2021
@colemanw
Copy link
Member

Looks good, thanks.

@colemanw colemanw merged commit 3d39544 into civicrm:5.43 Oct 16, 2021
@jensschuppe jensschuppe deleted the api4CreateRequestEvent branch October 18, 2021 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants