Skip to content

Commit

Permalink
[ENG-1011] Fix memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
heathdutton committed Aug 27, 2019
1 parent e1981b2 commit 7ff772b
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions Entity/ExtendedFieldRepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ private function getExtendedFieldValuesMultiple(
$extendedFieldList = [],
$leadIds = []
) {
$leads = [];

if (!$leadIds) {
return [];
return $leads;
}

/** @var EntityManager $em */
Expand Down Expand Up @@ -217,23 +219,12 @@ function ($e) {
EOSQL;

// Using executeQuery to ensure this can be executed on a slave MySQL.
$results = $connection->executeQuery($sql)->fetch(\PDO::FETCH_NUM);

// Group results by leadId.
$leads = [];
if ($results) {
foreach ($results as $row => $result) {
/*
* 0 = lead_id
* 1 = alias
* 2 = value
*/
if (!isset($leads[$result[0]])) {
$leads[$result[0]] = [];
}
$leads[$result[0]][$result[1]] = $result[2];
unset($results[$row]);
$stmt = $connection->executeQuery($sql);
while ($result = $stmt->fetch()) {
if (!isset($leads[$result['lead_id']])) {
$leads[$result['lead_id']] = [];
}
$leads[$result['lead_id']][$result['alias']] = $result['value'];
}

return $leads;
Expand Down

0 comments on commit 7ff772b

Please sign in to comment.