Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
perf(entities): entity preloader now correctly fetches entities
  • Loading branch information
jdalsem committed Jul 13, 2018
1 parent 21be3e8 commit c379dcd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engine/classes/Elgg/EntityPreloader.php
Expand Up @@ -3,6 +3,7 @@
namespace Elgg;

use Elgg\Database\EntityTable;
use Elgg\Database\Entities;

/**
* Preload entities based on properties of fetched objects
Expand Down Expand Up @@ -32,8 +33,8 @@ public function __construct(EntityTable $entity_table) {
$this->_callable_cache_checker = function ($guid) use ($entity_table) {
return $entity_table->getFromCache($guid);
};
$this->_callable_entity_loader = function ($options) use ($entity_table) {
return $entity_table->get($options);
$this->_callable_entity_loader = function ($options) {
return Entities::find($options);
};
}

Expand All @@ -48,6 +49,7 @@ public function __construct(EntityTable $entity_table) {
*/
public function preload($objects, array $guid_properties) {
$guids = $this->getGuidsToLoad($objects, $guid_properties);

// If only 1 to load, not worth the overhead of elgg_get_entities(),
// get_entity() will handle it later.
if (count($guids) > 1) {
Expand Down

0 comments on commit c379dcd

Please sign in to comment.