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

dev/core#562 Remove more DAO->free() calls #14071

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion CRM/Admin/Form/ScheduleReminders.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ public function postProcess() {

// we need to set this on the form so that hooks can identify the created entity
$this->set('id', $bao->id);
$bao->free();

$status = ts("Your new Reminder titled %1 has been saved.",
[1 => "<strong>{$values['title']}</strong>"]
Expand Down
2 changes: 0 additions & 2 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2945,7 +2945,6 @@ public static function getLocBlockIds($contactId, $criteria = array(), $condOper
while ($blockDAO->fetch()) {
$locBlockIds[$name][] = $blockDAO->id;
}
$blockDAO->free();
}

return $locBlockIds;
Expand Down Expand Up @@ -3556,7 +3555,6 @@ public static function deleteObjectWithPrimary($type, $id) {
}
}
CRM_Utils_Hook::post('delete', $type, $id, $obj);
$obj->free();
return TRUE;
}

Expand Down
3 changes: 0 additions & 3 deletions CRM/Contact/BAO/Contact/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ public static function currentEmployerRelatedMembership($contactID, $employerID,
$ids['relationship'] = $relationship->id;
CRM_Contact_BAO_Relationship::setIsActive($relationship->id, TRUE);
}
$relationship->free();
}

//need to handle related meberships. CRM-3792
Expand Down Expand Up @@ -457,7 +456,6 @@ public static function clearCurrentEmployer($contactId, $employerId = NULL) {
CRM_Core_Action::DELETE
);
}
$relationship->free();
}
}
}
Expand Down Expand Up @@ -799,7 +797,6 @@ public static function contactDetails($componentIds, $componentName, $returnProp
$contactDetails[$contact->componentId][$property] = $contact->$property;
}
}
$contact->free();
}

return $contactDetails;
Expand Down
1 change: 0 additions & 1 deletion CRM/Contact/BAO/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ public static function hasCustomData($contactType, $contactId = NULL) {

$customDataCount = CRM_Core_DAO::singleValueQuery($sql);
if (!empty($customDataCount)) {
$dao->free();
return TRUE;
}
}
Expand Down
1 change: 0 additions & 1 deletion CRM/Contact/BAO/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ public static function getGroupsHierarchy(
];
}
}
$dao->free();

$hierarchy = [];
for ($i = 0; $i < count($roots); $i++) {
Expand Down
5 changes: 0 additions & 5 deletions CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,6 @@ public static function add($params, $ids = array(), $contactId = NULL) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_relationship', $relationship->id);
}

$relationship->free();

CRM_Utils_Hook::post($hook, 'Relationship', $relationship->id, $relationship);

return $relationship;
Expand Down Expand Up @@ -959,11 +957,9 @@ public static function checkDuplicateRelationship(&$params, $id, $contactId = 0,
// Check whether the custom field values are identical.
$result = self::checkDuplicateCustomFields($params, $relationship->id);
if ($result) {
$relationship->free();
return TRUE;
}
}
$relationship->free();
return FALSE;
}

Expand Down Expand Up @@ -1450,7 +1446,6 @@ public static function getRelationship(
}
}

$relationship->free();
return $values;
}
}
Expand Down
1 change: 0 additions & 1 deletion CRM/Contact/BAO/RelationshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public static function retrieve(&$params, &$defaults) {
$relationshipType->copyValues($params);
if ($relationshipType->find(TRUE)) {
CRM_Core_DAO::storeValues($relationshipType, $defaults);
$relationshipType->free();
return $relationshipType;
}
return NULL;
Expand Down
3 changes: 0 additions & 3 deletions CRM/Contact/Form/DedupeRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ public function postProcess() {
$ruleDao = new CRM_Dedupe_DAO_Rule();
$ruleDao->dedupe_rule_group_id = $rgDao->id;
$ruleDao->delete();
$ruleDao->free();

$substrLenghts = [];

$tables = [];
Expand All @@ -267,7 +265,6 @@ public function postProcess() {
$ruleDao->rule_length = $length;
$ruleDao->rule_weight = $weight;
$ruleDao->save();
$ruleDao->free();

if (!array_key_exists($table, $tables)) {
$tables[$table] = [];
Expand Down
1 change: 0 additions & 1 deletion CRM/Contact/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ public function mergeContactIdsByHousehold() {
$this->_contactIds[] = $householdsDAO->household_id;
}
}
$householdsDAO->free();
}

// If contact list has changed, households will probably be at the end of
Expand Down
2 changes: 0 additions & 2 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) {
$formatting['contact_sub_type'] = $relationType->$direction;
}
}
$relationType->free();

$contactFields = NULL;
$contactFields = CRM_Contact_DAO_Contact::import();
Expand Down Expand Up @@ -1353,7 +1352,6 @@ public static function isErrorInCustomData($params, &$errorMessage, $csType = NU
$params[$key]['contact_sub_type'] = $relationshipType->$direction;
}
}
$relationshipType->free();
}

self::isErrorInCustomData($params[$key], $errorMessage, $csType, $relationships);
Expand Down
1 change: 0 additions & 1 deletion CRM/Contribute/Form/AbstractEditPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ public function assignPremiumProduct($id) {
$this->_premiumID = $dao->id;
$this->_productDAO = $dao;
}
$dao->free();
}

/**
Expand Down
1 change: 0 additions & 1 deletion CRM/Contribute/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public static function preProcessCommon(&$form) {
$contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
}
}
$result->free();
$form->assign('totalSelectedContributions', $form->get('rowCount'));
}

Expand Down
3 changes: 0 additions & 3 deletions CRM/Dedupe/BAO/RuleGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ public function fillTable() {
// get prepared to search within already found dupes if $searchWithinDupes flag is set
$dao->query("DROP TEMPORARY TABLE IF EXISTS dedupe_copy");
$dao->query("CREATE TEMPORARY TABLE dedupe_copy SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
$dao->free();

preg_match($patternColumn, $query, $matches);
$query = str_replace(' WHERE ', str_replace('column', $matches[1], $dupeCopyJoin), $query);
Expand All @@ -258,7 +257,6 @@ public function fillTable() {
// Make a second temp table:
$dao->query("DROP TEMPORARY TABLE IF EXISTS dedupe_copy_2");
$dao->query("CREATE TEMPORARY TABLE dedupe_copy_2 SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
$dao->free();
// After the union, use that new temp table:
$part1 = substr($query, 0, $matches[1][1]);
$query = $part1 . str_replace('dedupe_copy', 'dedupe_copy_2', substr($query, $matches[1][1]));
Expand All @@ -273,7 +271,6 @@ public function fillTable() {
// FIXME: we need to be more acurate with affected rows, especially for insert vs duplicate insert.
// And that will help optimize further.
$affectedRows = $dao->affectedRows();
$dao->free();

// In an inclusive situation, failure of any query means no further processing -
if ($affectedRows == 0) {
Expand Down
1 change: 0 additions & 1 deletion CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,6 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che
CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
}
}
$dao->free();

// move the other contact's file to main contact
//NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
Expand Down
1 change: 0 additions & 1 deletion CRM/Mailing/BAO/TrackableURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public static function getTrackerURL($url, $mailing_id, $queue_id) {
$tracker->save();
}
$id = $tracker->id;
$tracker->free();

$redirect = $config->userFrameworkResourceURL . "extern/url.php?u=$id";
$urlCache[$mailing_id . $url] = $redirect;
Expand Down
1 change: 0 additions & 1 deletion CRM/Mailing/Event/BAO/Delivered.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static function &create(&$params) {
if (!$q) {
return NULL;
}
$q->free();

$delivered = new CRM_Mailing_Event_BAO_Delivered();
$delivered->time_stamp = date('YmdHis');
Expand Down
2 changes: 0 additions & 2 deletions CRM/Mailing/Event/BAO/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public static function &subscribe($group_id, $email, $contactId = NULL, $context
if ($dao->fetch()) {
$contact_id = $dao->contact_id;
}
$dao->free();
}

$transaction = new CRM_Core_Transaction();
Expand Down Expand Up @@ -343,7 +342,6 @@ public static function getContactGroups($email, $contactID = NULL) {
];
}

$dao->free();
return $groups;
}

Expand Down
1 change: 0 additions & 1 deletion CRM/Report/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,6 @@ public function alterCustomDataDisplay(&$rows) {
while ($dao->fetch()) {
$customFields[$dao->table_name . '_custom_' . $dao->id] = $dao->id;
}
$dao->free();

$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
Expand Down
3 changes: 0 additions & 3 deletions CRM/Report/Form/Contribute/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ public function buildRows($sql, &$rows) {
while ($dao->fetch()) {
$contactIds[] = $dao->cid;
}
$dao->free();
$this->setPager();

$relationshipRows = [];
Expand Down Expand Up @@ -732,7 +731,6 @@ public function buildContributionRows($contactIds) {
}
$rows[$dao->civicrm_contact_id]['aggregate_amount'] += $dao->civicrm_contribution_total_amount;
}
$dao->free();
return $rows;
}

Expand Down Expand Up @@ -776,7 +774,6 @@ public function buildRelationshipRows($contactIds) {
$relatedContactIds[$dao->contact_id_a] = $dao->contact_id_a;
}
}
$dao->free();
return [$relationshipRows, $relatedContactIds];
}

Expand Down
1 change: 0 additions & 1 deletion Civi/Core/SettingsBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ protected function setDb($name, $value) {
// to save the field `group_name`, which is required in older schema.
\CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
}
$dao->free();
}

}