Skip to content

Commit

Permalink
Merge pull request #18692 from eileenmcnaughton/leak1
Browse files Browse the repository at this point in the history
dev/core#2073 Remove memory leak in heavily tested (merge) code
  • Loading branch information
seamuslee001 authored Oct 7, 2020
2 parents 829489b + 411f09c commit 0957ca2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions CRM/Dedupe/BAO/RuleGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ public function fillTable() {
$patternColumn = '/t1.(\w+)/';
$exclWeightSum = [];

$dao = new CRM_Core_DAO();
CRM_Utils_Hook::dupeQuery($this, 'table', $tableQueries);

while (!empty($tableQueries)) {
Expand Down Expand Up @@ -257,7 +256,7 @@ public function fillTable() {

// construct and execute the intermediate query
$query = "{$insertClause} {$query} {$groupByClause} ON DUPLICATE KEY UPDATE weight = weight + VALUES(weight)";
$dao->query($query);
$dao = CRM_Core_DAO::executeQuery($query);

// FIXME: we need to be more acurate with affected rows, especially for insert vs duplicate insert.
// And that will help optimize further.
Expand All @@ -279,7 +278,7 @@ public function fillTable() {
$fieldWeight = $fieldWeight[0];
$query = array_shift($tableQueries);
$query = "{$insertClause} {$query} {$groupByClause} ON DUPLICATE KEY UPDATE weight = weight + VALUES(weight)";
$dao->query($query);
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->affectedRows() >= 1) {
$exclWeightSum[] = substr($fieldWeight, strrpos($fieldWeight, '.') + 1);
}
Expand Down
5 changes: 2 additions & 3 deletions CRM/Dedupe/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ public static function dupes($rgid, $cids = [], $checkPermissions = TRUE) {
}

$rgBao->fillTable();
$dao = new CRM_Core_DAO();
$dao->query($rgBao->thresholdQuery($checkPermissions));
$dao = CRM_Core_DAO::executeQuery($rgBao->thresholdQuery($checkPermissions));
$dupes = [];
while ($dao->fetch()) {
$dupes[] = [$dao->id1, $dao->id2, $dao->weight];
}
$dao->query($rgBao->tableDropQuery());
CRM_Core_DAO::executeQuery(($rgBao->tableDropQuery()));

return $dupes;
}
Expand Down

0 comments on commit 0957ca2

Please sign in to comment.