dev/core#562 Remove more DAO->free() calls
authoreileen <emcnaughton@wikimedia.org>
Tue, 16 Apr 2019 21:12:22 +0000 (07:12 +1000)
committereileen <emcnaughton@wikimedia.org>
Tue, 16 Apr 2019 21:12:22 +0000 (07:12 +1000)
We have been removing a few of these each release. They no longer provide any benefit
as the resources are released in the deconstructor. OTOH they can in rare circumstances cause bugs.

Previous removals have not caused any issues so the slow approach is starting to
look overly cautious now

20 files changed:
CRM/Admin/Form/ScheduleReminders.php
CRM/Contact/BAO/Contact.php
CRM/Contact/BAO/Contact/Utils.php
CRM/Contact/BAO/ContactType.php
CRM/Contact/BAO/Group.php
CRM/Contact/BAO/Relationship.php
CRM/Contact/BAO/RelationshipType.php
CRM/Contact/Form/DedupeRules.php
CRM/Contact/Form/Task.php
CRM/Contact/Import/Parser/Contact.php
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/Task.php
CRM/Dedupe/BAO/RuleGroup.php
CRM/Dedupe/Merger.php
CRM/Mailing/BAO/TrackableURL.php
CRM/Mailing/Event/BAO/Delivered.php
CRM/Mailing/Event/BAO/Subscribe.php
CRM/Report/Form.php
CRM/Report/Form/Contribute/History.php
Civi/Core/SettingsBag.php

index 38e425bfd5f0b926a6061e3b88e254577baf8007..e2365cb9d01e38fe9688c7c6e477de3d387c7ad1 100644 (file)
@@ -463,7 +463,6 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
 
     // 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>"]
index f1fb6929d82ea39bbe3ff8818f790d080fecfe17..d2bc999452e7a8a7accd46dd447d549a4053e3ce 100644 (file)
@@ -2945,7 +2945,6 @@ AND       civicrm_openid.is_primary = 1";
       while ($blockDAO->fetch()) {
         $locBlockIds[$name][] = $blockDAO->id;
       }
-      $blockDAO->free();
     }
 
     return $locBlockIds;
@@ -3556,7 +3555,6 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id )
       }
     }
     CRM_Utils_Hook::post('delete', $type, $id, $obj);
-    $obj->free();
     return TRUE;
   }
 
index 2b3f0879133a708bb6380fb22cc9f9d70deb0031..81a93b376c9fd753645f0214df1d99d8f774b351 100644 (file)
@@ -374,7 +374,6 @@ UNION
         $ids['relationship'] = $relationship->id;
         CRM_Contact_BAO_Relationship::setIsActive($relationship->id, TRUE);
       }
-      $relationship->free();
     }
 
     //need to handle related meberships. CRM-3792
@@ -457,7 +456,6 @@ WHERE id={$contactId}; ";
             CRM_Core_Action::DELETE
           );
         }
-        $relationship->free();
       }
     }
   }
@@ -799,7 +797,6 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i
           $contactDetails[$contact->componentId][$property] = $contact->$property;
         }
       }
-      $contact->free();
     }
 
     return $contactDetails;
index 897fcbc6f886bd53afd154d294fde35f2abeba4e..b0d25258ef6d60ea2280d4a4781cff46659651c7 100644 (file)
@@ -785,7 +785,6 @@ WHERE name = %1";
 
       $customDataCount = CRM_Core_DAO::singleValueQuery($sql);
       if (!empty($customDataCount)) {
-        $dao->free();
         return TRUE;
       }
     }
index 94d8852e9ab847aa9f1329b955304e7c803410aa..e7ec4a8de8226d1b8056c786ec29babdd1824da4 100644 (file)
@@ -1112,7 +1112,6 @@ WHERE  id IN $groupIdString
         ];
       }
     }
-    $dao->free();
 
     $hierarchy = [];
     for ($i = 0; $i < count($roots); $i++) {
index d5c76f345e840558fabe62e1d2b7fdfcba1891af..e271d16cb1332e6dc4d7b7d60e7c2ba4cdba2f64 100644 (file)
@@ -344,8 +344,6 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
       CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_relationship', $relationship->id);
     }
 
-    $relationship->free();
-
     CRM_Utils_Hook::post($hook, 'Relationship', $relationship->id, $relationship);
 
     return $relationship;
@@ -959,11 +957,9 @@ WHERE  relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
       // Check whether the custom field values are identical.
       $result = self::checkDuplicateCustomFields($params, $relationship->id);
       if ($result) {
-        $relationship->free();
         return TRUE;
       }
     }
-    $relationship->free();
     return FALSE;
   }
 
@@ -1450,7 +1446,6 @@ LEFT JOIN  civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
         }
       }
 
-      $relationship->free();
       return $values;
     }
   }
index e229a03ea5718ee40692998d53cc479b0a43f18c..bc11bf2f0248ec9b041eae625072a1c6c0fc8266 100644 (file)
@@ -54,7 +54,6 @@ class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType
     $relationshipType->copyValues($params);
     if ($relationshipType->find(TRUE)) {
       CRM_Core_DAO::storeValues($relationshipType, $defaults);
-      $relationshipType->free();
       return $relationshipType;
     }
     return NULL;
index 82bd6ef93f6ab7337a231696d37e918f2a56ef19..c33f4d5010e7d3534ffb4fc6a431ae4e937ecd0d 100644 (file)
@@ -245,8 +245,6 @@ UPDATE civicrm_dedupe_rule_group
     $ruleDao = new CRM_Dedupe_DAO_Rule();
     $ruleDao->dedupe_rule_group_id = $rgDao->id;
     $ruleDao->delete();
-    $ruleDao->free();
-
     $substrLenghts = [];
 
     $tables = [];
@@ -267,7 +265,6 @@ UPDATE civicrm_dedupe_rule_group
         $ruleDao->rule_length = $length;
         $ruleDao->rule_weight = $weight;
         $ruleDao->save();
-        $ruleDao->free();
 
         if (!array_key_exists($table, $tables)) {
           $tables[$table] = [];
index 9448c3b59c55b6e2e72d3bf30374656a15a85c4a..8e1c3a3aa14543abacc470e6728522606ad855a2 100644 (file)
@@ -453,7 +453,6 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
           $this->_contactIds[] = $householdsDAO->household_id;
         }
       }
-      $householdsDAO->free();
     }
 
     // If contact list has changed, households will probably be at the end of
index 663aa55101cf5ddac3d3a6ce1a8787b2c84c7166..542a65ba556588e5d0e67241774298bae0ec9201 100644 (file)
@@ -820,7 +820,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
               $formatting['contact_sub_type'] = $relationType->$direction;
             }
           }
-          $relationType->free();
 
           $contactFields = NULL;
           $contactFields = CRM_Contact_DAO_Contact::import();
@@ -1353,7 +1352,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
               $params[$key]['contact_sub_type'] = $relationshipType->$direction;
             }
           }
-          $relationshipType->free();
         }
 
         self::isErrorInCustomData($params[$key], $errorMessage, $csType, $relationships);
index 1eacda32bb1f0a020852b899f52a7f0e8854c2c4..f410a2bf7130f6d5fb9023ae01d05c22c5c78d1f 100644 (file)
@@ -343,7 +343,6 @@ WHERE  contribution_id = {$id}
       $this->_premiumID = $dao->id;
       $this->_productDAO = $dao;
     }
-    $dao->free();
   }
 
   /**
index 8e6eb1d3ad3c9a249d8dd877fb17b8b426d637ff..fac10e2ac666ff28d362c845163ec9437f7c9d51 100644 (file)
@@ -137,7 +137,6 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task {
           $contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
         }
       }
-      $result->free();
       $form->assign('totalSelectedContributions', $form->get('rowCount'));
     }
 
index b6dab2843a97fc3ae7be1ebee9bd369f9263d920..61f70b2d279e9c8b69746edae9c8847b3ee2721e 100644 (file)
@@ -247,7 +247,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
             // 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);
@@ -258,7 +257,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
               // 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]));
@@ -273,7 +271,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
           // 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) {
index ceea27b4e854b69d56d5bbf864521acb167093f5..869454b0ca23b997f1fa0d538fbff87713fb74c5 100644 (file)
@@ -1830,7 +1830,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
           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
index 6c5b6590f2d9823ff8b6be45a7cc214e97b466ed..da57a134c3eb8674234aa1318cc8dc01a9c8cd4d 100644 (file)
@@ -88,7 +88,6 @@ class CRM_Mailing_BAO_TrackableURL extends CRM_Mailing_DAO_TrackableURL {
         $tracker->save();
       }
       $id = $tracker->id;
-      $tracker->free();
 
       $redirect = $config->userFrameworkResourceURL . "extern/url.php?u=$id";
       $urlCache[$mailing_id . $url] = $redirect;
index 706a65d2151ef9d9d0403740a4ef237f9179f2c8..e8c9a4cc19b6a1e285f250661d43f073b40d17fe 100644 (file)
@@ -56,7 +56,6 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered {
     if (!$q) {
       return NULL;
     }
-    $q->free();
 
     $delivered = new CRM_Mailing_Event_BAO_Delivered();
     $delivered->time_stamp = date('YmdHis');
index b020f76ad7c44192ba4fadd89dacb54f60bbe994..393216364ee45ea999df3e71ddd9c7282ba246c0 100644 (file)
@@ -97,7 +97,6 @@ LEFT JOIN civicrm_email      ON contact_a.id = civicrm_email.contact_id
       if ($dao->fetch()) {
         $contact_id = $dao->contact_id;
       }
-      $dao->free();
     }
 
     $transaction = new CRM_Core_Transaction();
@@ -343,7 +342,6 @@ SELECT     civicrm_email.id as email_id
       ];
     }
 
-    $dao->free();
     return $groups;
   }
 
index 7d9ae9c0fec45f9a2dbb7b657b67d5bb9bd7610c..e45e516d76032589513bfca85e7de0b93fa25438 100644 (file)
@@ -2237,7 +2237,6 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     while ($dao->fetch()) {
       $customFields[$dao->table_name . '_custom_' . $dao->id] = $dao->id;
     }
-    $dao->free();
 
     $entryFound = FALSE;
     foreach ($rows as $rowNum => $row) {
index 584bd347da739d45e94c2cc0fbe7609434809341..321b6317c580f00d25c3998070e0d91203a77044 100644 (file)
@@ -617,7 +617,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
     while ($dao->fetch()) {
       $contactIds[] = $dao->cid;
     }
-    $dao->free();
     $this->setPager();
 
     $relationshipRows = [];
@@ -732,7 +731,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
       }
       $rows[$dao->civicrm_contact_id]['aggregate_amount'] += $dao->civicrm_contribution_total_amount;
     }
-    $dao->free();
     return $rows;
   }
 
@@ -776,7 +774,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
         $relatedContactIds[$dao->contact_id_a] = $dao->contact_id_a;
       }
     }
-    $dao->free();
     return [$relationshipRows, $relatedContactIds];
   }
 
index 613703305ac04f217598be20536f2020e30b6094..86d48bbb791e713400f320fc7fb0791a055127dd 100644 (file)
@@ -392,7 +392,6 @@ class SettingsBag {
       // 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();
   }
 
 }