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

REF - Fix loop in APIv4 Entity.get to only load ad-hoc entities once #21819

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Civi/Api4/Action/Entity/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ protected function getRecords() {
$entities = $cache->get('api4.entities.info', []);

if (!$entities) {
// Load entities declared in API files
foreach ($this->getAllApiClasses() as $className) {
// Load entities declared in API files
$this->loadEntity($className, $entities);
// Load entities based on custom data
$entities = array_merge($entities, $this->getCustomEntities());
// Allow extensions to modify the list of entities
$event = GenericHookEvent::create(['entities' => &$entities]);
\Civi::dispatcher()->dispatch('civi.api4.entityTypes', $event);
}
// Load entities based on custom data
$entities = array_merge($entities, $this->getCustomEntities());
// Allow extensions to modify the list of entities
$event = GenericHookEvent::create(['entities' => &$entities]);
\Civi::dispatcher()->dispatch('civi.api4.entityTypes', $event);
ksort($entities);
$cache->set('api4.entities.info', $entities);
}
Expand Down