From 1273d77c64386bcc2f5da087cefaa0c480fb02e0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 11 Nov 2016 17:21:09 -0500 Subject: [PATCH] CRM-17335 - Remove more uses of CRM_Core_DAO::$_nullObject --- CRM/Activity/Form/Search.php | 12 ++------ CRM/Batch/Form/Entry.php | 2 +- CRM/Case/Form/Search.php | 20 ++++--------- CRM/Contact/BAO/Contact.php | 12 ++++---- CRM/Contact/Form/Edit/Address.php | 2 +- CRM/Contact/Form/Search/Custom/Sample.php | 4 +-- CRM/Contact/Page/View.php | 4 +-- CRM/Contact/Page/View/Note.php | 5 +--- CRM/Contact/Page/View/Relationship.php | 5 +--- CRM/Contact/Page/View/UserDashBoard.php | 4 +-- CRM/Contribute/BAO/ContributionPage.php | 3 +- CRM/Contribute/BAO/ContributionRecur.php | 2 +- CRM/Contribute/Form/CancelSubscription.php | 4 +-- CRM/Contribute/Form/Search.php | 16 +++-------- CRM/Contribute/Form/Task/Invoice.php | 8 ++---- CRM/Contribute/Form/UpdateBilling.php | 4 +-- CRM/Contribute/Form/UpdateSubscription.php | 4 +-- CRM/Core/BAO/File.php | 2 +- CRM/Core/BAO/Log.php | 2 +- CRM/Core/BAO/Note.php | 4 +-- CRM/Core/BAO/UFGroup.php | 2 +- CRM/Core/Block.php | 4 +-- CRM/Core/DAO.php | 11 ++++++-- CRM/Core/PseudoConstant.php | 8 +++--- CRM/Dedupe/Merger.php | 2 +- CRM/Event/Form/ManageEvent/Location.php | 2 +- CRM/Event/Form/Search.php | 16 +++-------- CRM/Grant/Form/Search.php | 4 +-- CRM/Grant/Page/Tab.php | 5 +--- CRM/Member/Form/Search.php | 28 +++++-------------- CRM/Pledge/Form/Search.php | 8 ++---- CRM/Report/Form.php | 14 ++-------- CRM/Utils/Hook.php | 2 +- api/v3/Generic/Setvalue.php | 2 +- api/v3/utils.php | 2 +- .../Contribute/BAO/ContributionRecurTest.php | 2 +- .../CRM/Contribute/Form/Task/InvoiceTest.php | 4 +-- 37 files changed, 76 insertions(+), 159 deletions(-) diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index fcb0902331..9cd9c78b1a 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -314,9 +314,7 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { // Added for membership search - $signupType = CRM_Utils_Request::retrieve('signupType', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $signupType = CRM_Utils_Request::retrieve('signupType', 'Positive'); if ($signupType) { $this->_formValues['activity_role'] = 1; @@ -342,9 +340,7 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { } } - $dateLow = CRM_Utils_Request::retrieve('dateLow', 'String', - CRM_Core_DAO::$_nullObject - ); + $dateLow = CRM_Utils_Request::retrieve('dateLow', 'String'); if ($dateLow) { $dateLow = date('m/d/Y', strtotime($dateLow)); @@ -354,9 +350,7 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { $this->_defaults['activity_date_low'] = $dateLow; } - $dateHigh = CRM_Utils_Request::retrieve('dateHigh', 'String', - CRM_Core_DAO::$_nullObject - ); + $dateHigh = CRM_Utils_Request::retrieve('dateHigh', 'String'); if ($dateHigh) { // Activity date time assumes midnight at the beginning of the date diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 60e0f58aac..297d41f5b3 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -551,7 +551,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { } $value['line_item'] = $lineItem; //finally call contribution create for all the magic - $contribution = CRM_Contribute_BAO_Contribution::create($value, CRM_Core_DAO::$_nullArray); + $contribution = CRM_Contribute_BAO_Contribution::create($value); $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate'); if (!empty($this->_batchInfo['type_id']) && ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment'])) { $adjustTotalAmount = FALSE; diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index 124237a4e1..bbbb1f5d1e 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -356,33 +356,25 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { return; } - $caseStatus = CRM_Utils_Request::retrieve('status', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $caseStatus = CRM_Utils_Request::retrieve('status', 'Positive'); if ($caseStatus) { $this->_formValues['case_status_id'] = $caseStatus; $this->_defaults['case_status_id'] = $caseStatus; } - $caseType = CRM_Utils_Request::retrieve('type', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $caseType = CRM_Utils_Request::retrieve('type', 'Positive'); if ($caseType) { $this->_formValues['case_type_id'] = (array) $caseType; $this->_defaults['case_type_id'] = (array) $caseType; } - $caseFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', - CRM_Core_DAO::$_nullObject - ); + $caseFromDate = CRM_Utils_Request::retrieve('pstart', 'Date'); if ($caseFromDate) { list($date) = CRM_Utils_Date::setDateDefaults($caseFromDate); $this->_formValues['case_start_date_low'] = $date; $this->_defaults['case_start_date_low'] = $date; } - $caseToDate = CRM_Utils_Request::retrieve('pend', 'Date', - CRM_Core_DAO::$_nullObject - ); + $caseToDate = CRM_Utils_Request::retrieve('pend', 'Date'); if ($caseToDate) { list($date) = CRM_Utils_Date::setDateDefaults($caseToDate); $this->_formValues['case_start_date_high'] = $date; @@ -415,9 +407,7 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { } // Now if case_owner is set in the url/post, use that instead. - $caseOwner = CRM_Utils_Request::retrieve('case_owner', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $caseOwner = CRM_Utils_Request::retrieve('case_owner', 'Positive'); if ($caseOwner) { $this->_formValues['case_owner'] = $caseOwner; $this->_defaults['case_owner'] = $caseOwner; diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index b90ccd47d3..4a8b1ae715 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2330,10 +2330,10 @@ ORDER BY civicrm_email.is_primary DESC"; * @param string $ctype * Contact type. * - * @return object + * @return object|null * $dao contact details */ - public static function &matchContactOnEmail($mail, $ctype = NULL) { + public static function matchContactOnEmail($mail, $ctype = NULL) { $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; $mail = $strtolower(trim($mail)); $query = " @@ -2370,7 +2370,7 @@ WHERE civicrm_email.email = %1 AND civicrm_contact.is_deleted=0"; if ($dao->fetch()) { return $dao; } - return CRM_Core_DAO::$_nullObject; + return NULL; } /** @@ -2381,10 +2381,10 @@ WHERE civicrm_email.email = %1 AND civicrm_contact.is_deleted=0"; * @param string $ctype * Contact type. * - * @return object + * @return object|null * $dao contact details */ - public static function &matchContactOnOpenId($openId, $ctype = NULL) { + public static function matchContactOnOpenId($openId, $ctype = NULL) { $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; $openId = $strtolower(trim($openId)); $query = " @@ -2409,7 +2409,7 @@ WHERE civicrm_openid.openid = %1"; if ($dao->fetch()) { return $dao; } - return CRM_Core_DAO::$_nullObject; + return NULL; } /** diff --git a/CRM/Contact/Form/Edit/Address.php b/CRM/Contact/Form/Edit/Address.php index 158ecc13a7..cbf8f00152 100644 --- a/CRM/Contact/Form/Edit/Address.php +++ b/CRM/Contact/Form/Edit/Address.php @@ -240,7 +240,7 @@ class CRM_Contact_Form_Edit_Address { * @return array|bool * if no errors */ - public static function formRule($fields, $files, $self) { + public static function formRule($fields, $files = array(), $self = NULL) { $errors = array(); $customDataRequiredFields = array(); diff --git a/CRM/Contact/Form/Search/Custom/Sample.php b/CRM/Contact/Form/Search/Custom/Sample.php index 9ef5b0c073..e0bf1543c3 100644 --- a/CRM/Contact/Form/Search/Custom/Sample.php +++ b/CRM/Contact/Form/Search/Custom/Sample.php @@ -42,9 +42,7 @@ class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Cust parent::__construct($formValues); if (!isset($formValues['state_province_id'])) { - $this->_stateID = CRM_Utils_Request::retrieve('stateID', 'Integer', - CRM_Core_DAO::$_nullObject - ); + $this->_stateID = CRM_Utils_Request::retrieve('stateID', 'Integer'); if ($this->_stateID) { $formValues['state_province_id'] = $this->_stateID; } diff --git a/CRM/Contact/Page/View.php b/CRM/Contact/Page/View.php index 6536352a08..4ccd2a4925 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -365,9 +365,7 @@ class CRM_Contact_Page_View extends CRM_Core_Page { CRM_Utils_Hook::links('view.contact.activity', 'Contact', $cid, - $hookLinks, - CRM_Core_DAO::$_nullObject, - CRM_Core_DAO::$_nullObject + $hookLinks ); if (is_array($hookLinks)) { $obj->assign('hookLinks', $hookLinks); diff --git a/CRM/Contact/Page/View/Note.php b/CRM/Contact/Page/View/Note.php index 1b9a134504..550cda41f2 100644 --- a/CRM/Contact/Page/View/Note.php +++ b/CRM/Contact/Page/View/Note.php @@ -166,10 +166,7 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { ); $session->pushUserContext($url); - if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', - CRM_Core_DAO::$_nullObject - ) - ) { + if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) { CRM_Core_BAO_Note::del($this->_id); CRM_Utils_System::redirect($url); } diff --git a/CRM/Contact/Page/View/Relationship.php b/CRM/Contact/Page/View/Relationship.php index 1e44f43e7c..32b71d75e6 100644 --- a/CRM/Contact/Page/View/Relationship.php +++ b/CRM/Contact/Page/View/Relationship.php @@ -157,10 +157,7 @@ class CRM_Contact_Page_View_Relationship extends CRM_Core_Page { $session->pushUserContext($url); - if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', - CRM_Core_DAO::$_nullObject - ) - ) { + if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) { if ($this->_caseId) { //create an activity for case role removal.CRM-4480 CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $this->_id); diff --git a/CRM/Contact/Page/View/UserDashBoard.php b/CRM/Contact/Page/View/UserDashBoard.php index a4ba1d3f00..c46eea0f59 100644 --- a/CRM/Contact/Page/View/UserDashBoard.php +++ b/CRM/Contact/Page/View/UserDashBoard.php @@ -243,9 +243,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page { CRM_Utils_Hook::links('view.contact.userDashBoard', 'Contact', CRM_Core_DAO::$_nullObject, - self::$_links, - CRM_Core_DAO::$_nullObject, - CRM_Core_DAO::$_nullObject + self::$_links ); return self::$_links; } diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 15902f3c60..ef60f98f26 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -958,8 +958,7 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm 'output' => 'pdf_invoice', 'forPage' => 'confirmpage', ); - $pdfHtml = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID, - $pdfParams, $contactId, CRM_Core_DAO::$_nullObject); + $pdfHtml = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID, $pdfParams, $contactId); return $pdfHtml; } diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 5fd0b09efa..276c7677d0 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -305,7 +305,7 @@ SELECT r.payment_processor_id } // if there are associated objects, cancel them as well - if ($objects == CRM_Core_DAO::$_nullObject) { + if (!$objects) { $transaction->commit(); return TRUE; } diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index 817fc58af8..c96101884f 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -100,7 +100,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form { if ( (!$this->_crid && !$this->_coid && !$this->_mid) || - ($this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) + (!$this->_subscriptionDetails) ) { CRM_Core_Error::fatal('Required information missing.'); } @@ -224,7 +224,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form { ); $cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution( $this->_subscriptionDetails->recur_id, - CRM_Core_DAO::$_nullObject, + NULL, $activityParams ); diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index 1826982d18..a2b8b89861 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -382,9 +382,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { return; } - $status = CRM_Utils_Request::retrieve('status', 'String', - CRM_Core_DAO::$_nullObject - ); + $status = CRM_Utils_Request::retrieve('status', 'String'); if ($status) { $this->_formValues['contribution_status_id'] = array($status => 1); $this->_defaults['contribution_status_id'] = array($status => 1); @@ -406,18 +404,14 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { } } - $lowDate = CRM_Utils_Request::retrieve('start', 'Timestamp', - CRM_Core_DAO::$_nullObject - ); + $lowDate = CRM_Utils_Request::retrieve('start', 'Timestamp'); if ($lowDate) { $lowDate = CRM_Utils_Type::escape($lowDate, 'Timestamp'); $date = CRM_Utils_Date::setDateDefaults($lowDate); $this->_formValues['contribution_date_low'] = $this->_defaults['contribution_date_low'] = $date[0]; } - $highDate = CRM_Utils_Request::retrieve('end', 'Timestamp', - CRM_Core_DAO::$_nullObject - ); + $highDate = CRM_Utils_Request::retrieve('end', 'Timestamp'); if ($highDate) { $highDate = CRM_Utils_Type::escape($highDate, 'Timestamp'); $date = CRM_Utils_Date::setDateDefaults($highDate); @@ -433,9 +427,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $this ); - $test = CRM_Utils_Request::retrieve('test', 'Boolean', - CRM_Core_DAO::$_nullObject - ); + $test = CRM_Utils_Request::retrieve('test', 'Boolean'); if (isset($test)) { $test = CRM_Utils_Type::escape($test, 'Boolean'); $this->_formValues['contribution_test'] = $test; diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index e0a99e21b8..776362dff9 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -223,7 +223,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { */ public function postProcess() { $params = $this->controller->exportValues($this->_name); - $this->printPDF($this->_contributionIds, $params, $this->_contactIds, $this); + self::printPDF($this->_contributionIds, $params, $this->_contactIds); } /** @@ -235,10 +235,8 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { * Associated array of submitted values. * @param array $contactIds * Contact Id. - * @param CRM_Core_Form $form - * Form object. */ - public static function printPDF($contribIDs, &$params, $contactIds, &$form) { + public static function printPDF($contribIDs, &$params, $contactIds) { // get all the details needed to generate a invoice $messageInvoice = array(); $invoiceTemplate = CRM_Core_Smarty::singleton(); @@ -663,7 +661,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $contributionIDs = array($contributionId); $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE); $params = array('output' => 'pdf_invoice'); - CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs, $params, $contactId, CRM_Core_DAO::$_nullObject); + CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs, $params, $contactId); } } diff --git a/CRM/Contribute/Form/UpdateBilling.php b/CRM/Contribute/Form/UpdateBilling.php index 683f94c0e1..a46bb7a236 100644 --- a/CRM/Contribute/Form/UpdateBilling.php +++ b/CRM/Contribute/Form/UpdateBilling.php @@ -86,9 +86,7 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Core_Form { $this->_mode = 'auto_renew'; } - if ((!$this->_crid && !$this->_coid && !$this->_mid) || - ($this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) - ) { + if ((!$this->_crid && !$this->_coid && !$this->_mid) || (!$this->_subscriptionDetails)) { CRM_Core_Error::fatal('Required information missing.'); } if (!CRM_Core_Permission::check('edit contributions')) { diff --git a/CRM/Contribute/Form/UpdateSubscription.php b/CRM/Contribute/Form/UpdateSubscription.php index c3ff12ae30..8647a6d5c0 100644 --- a/CRM/Contribute/Form/UpdateSubscription.php +++ b/CRM/Contribute/Form/UpdateSubscription.php @@ -100,9 +100,7 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Core_Form { $this->_coid = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->contributionRecurID, 'id', 'contribution_recur_id'); } - if ((!$this->contributionRecurID) || - ($this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) - ) { + if (!$this->contributionRecurID || !$this->_subscriptionDetails) { CRM_Core_Error::fatal('Required information missing.'); } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index c2480ad9b8..b5eac4825e 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -165,7 +165,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { //save free tags if (isset($fileParams['attachment_taglist']) && !empty($fileParams['attachment_taglist'])) { - CRM_Core_Form_Tag::postProcess($fileParams['attachment_taglist'], $entityFileDAO->id, 'civicrm_file', CRM_Core_DAO::$_nullObject); + CRM_Core_Form_Tag::postProcess($fileParams['attachment_taglist'], $entityFileDAO->id, 'civicrm_file'); } // lets call the post hook here so attachments code can do the right stuff diff --git a/CRM/Core/BAO/Log.php b/CRM/Core/BAO/Log.php index 8e669e900f..878970f9f1 100644 --- a/CRM/Core/BAO/Log.php +++ b/CRM/Core/BAO/Log.php @@ -53,7 +53,7 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log { $log->entity_id = $id; $log->orderBy('modified_date desc'); $log->limit(1); - $result = CRM_Core_DAO::$_nullObject; + $result = NULL; if ($log->find(TRUE)) { list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); $result = array( diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index 0a4d6a22cb..430d8821fd 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -134,13 +134,13 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { * @param array $ids * (deprecated) associated array with note id - preferably set $params['id']. * - * @return object + * @return object|null * $note CRM_Core_BAO_Note object */ public static function add(&$params, $ids = array()) { $dataExists = self::dataExists($params); if (!$dataExists) { - return CRM_Core_DAO::$_nullObject; + return NULL; } if (!empty($params['entity_table']) && $params['entity_table'] == 'civicrm_contact' && !empty($params['check_permissions'])) { diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index cdfe268505..15cb5349a8 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -3301,7 +3301,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ); $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $subTree); } - $formattedGroupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject); + $formattedGroupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1); CRM_Core_BAO_CustomGroup::setDefaults($formattedGroupTree, $defaults); } diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index 766837ab13..835da4796d 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -421,9 +421,7 @@ class CRM_Core_Block { CRM_Utils_Hook::links('create.new.shorcuts', NULL, CRM_Core_DAO::$_nullObject, - $values, - CRM_Core_DAO::$_nullObject, - CRM_Core_DAO::$_nullObject + $values ); foreach ($values as $key => $val) { diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 62deb2cfed..4a1660fbd9 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -47,9 +47,14 @@ require_once 'CRM/Core/I18n.php'; class CRM_Core_DAO extends DB_DataObject { /** - * A null object so we can pass it as reference if / when needed + * @var null + * @deprecated */ static $_nullObject = NULL; + /** + * @var array + * @deprecated + */ static $_nullArray = array(); static $_dbColumnValueCache = NULL; @@ -1529,7 +1534,7 @@ FROM civicrm_domain * @param $toId * @param array $newData * - * @return null + * @return CRM_Core_DAO|null */ public static function cascadeUpdate($daoName, $fromId, $toId, $newData = array()) { $object = new $daoName(); @@ -1563,7 +1568,7 @@ FROM civicrm_domain return $newObject; } } - return CRM_Core_DAO::$_nullObject; + return NULL; } /** diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 51a4b56eba..344259f0d8 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -789,7 +789,7 @@ WHERE id = %1"; * * @param bool $applyLimit * - * @return array + * @return array|null * array reference of all countries. */ public static function country($id = FALSE, $applyLimit = TRUE) { @@ -846,7 +846,7 @@ WHERE id = %1"; return self::$country[$id]; } else { - return CRM_Core_DAO::$_nullObject; + return NULL; } } return self::$country; @@ -1618,12 +1618,12 @@ ORDER BY name"; * * @param int $stateID * - * @return int + * @return int|null * the country id that the state belongs to */ public static function countryIDForStateID($stateID) { if (empty($stateID)) { - return CRM_Core_DAO::$_nullObject; + return NULL; } $query = " diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 11938d4934..0ba3ac1a84 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1727,7 +1727,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m CRM_Contact_BAO_Contact::createProfileContact($submitted, CRM_Core_DAO::$_nullArray, $mainId); } - CRM_Utils_Hook::post('merge', 'Contact', $mainId, CRM_Core_DAO::$_nullObject); + CRM_Utils_Hook::post('merge', 'Contact', $mainId); self::createMergeActivities($mainId, $otherId); return TRUE; diff --git a/CRM/Event/Form/ManageEvent/Location.php b/CRM/Event/Form/ManageEvent/Location.php index ce64515b52..103ec8f2e9 100644 --- a/CRM/Event/Form/ManageEvent/Location.php +++ b/CRM/Event/Form/ManageEvent/Location.php @@ -138,7 +138,7 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { */ public static function formRule($fields) { // check for state/country mapping - $errors = CRM_Contact_Form_Edit_Address::formRule($fields, CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullObject); + $errors = CRM_Contact_Form_Edit_Address::formRule($fields); return empty($errors) ? TRUE : $errors; } diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index efa172d63c..417643f5ef 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -405,17 +405,13 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { // if this search has been forced // then see if there are any get values, and if so over-ride the post values // note that this means that GET over-rides POST :) - $event = CRM_Utils_Request::retrieve('event', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $event = CRM_Utils_Request::retrieve('event', 'Positive'); if ($event) { $this->_formValues['event_id'] = $event; $this->_formValues['event_name'] = CRM_Event_PseudoConstant::event($event, TRUE); } - $status = CRM_Utils_Request::retrieve('status', 'String', - CRM_Core_DAO::$_nullObject - ); + $status = CRM_Utils_Request::retrieve('status', 'String'); if (isset($status)) { if ($status === 'true') { @@ -433,9 +429,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $this->_formValues['participant_status_id'] = is_array($statusTypes) ? array('IN' => array_keys($statusTypes)) : $statusTypes; } - $role = CRM_Utils_Request::retrieve('role', 'String', - CRM_Core_DAO::$_nullObject - ); + $role = CRM_Utils_Request::retrieve('role', 'String'); if (isset($role)) { if ($role === 'true') { @@ -450,9 +444,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $this->_formValues['participant_role_id'] = is_array($roleTypes) ? array_keys($roleTypes) : $roleTypes; } - $type = CRM_Utils_Request::retrieve('type', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $type = CRM_Utils_Request::retrieve('type', 'Positive'); if ($type) { $this->_formValues['event_type'] = $type; } diff --git a/CRM/Grant/Form/Search.php b/CRM/Grant/Form/Search.php index 0119f20ff0..7ed0756607 100644 --- a/CRM/Grant/Form/Search.php +++ b/CRM/Grant/Form/Search.php @@ -284,9 +284,7 @@ class CRM_Grant_Form_Search extends CRM_Core_Form_Search { return; } - $status = CRM_Utils_Request::retrieve('status', 'String', - CRM_Core_DAO::$_nullObject - ); + $status = CRM_Utils_Request::retrieve('status', 'String'); if ($status) { $this->_formValues['grant_status_id'] = $status; $this->_defaults['grant_status_id'] = $status; diff --git a/CRM/Grant/Page/Tab.php b/CRM/Grant/Page/Tab.php index 2a446f18b4..0076e54650 100644 --- a/CRM/Grant/Page/Tab.php +++ b/CRM/Grant/Page/Tab.php @@ -198,10 +198,7 @@ class CRM_Grant_Page_Tab extends CRM_Contact_Page_View { } $session->pushUserContext($url); - if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', - CRM_Core_DAO::$_nullObject - ) - ) { + if (CRM_Utils_Request::retrieve('confirmed', 'Boolean')) { CRM_Grant_BAO_Grant::del($this->_id); CRM_Utils_System::redirect($url); } diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index 5388496d40..c9bd8e4e82 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -296,26 +296,20 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { return; } - $status = CRM_Utils_Request::retrieve('status', 'String', - CRM_Core_DAO::$_nullObject - ); + $status = CRM_Utils_Request::retrieve('status', 'String'); if ($status) { $status = explode(',', $status); $this->_formValues['membership_status_id'] = $this->_defaults['membership_status_id'] = (array) $status; } - $membershipType = CRM_Utils_Request::retrieve('type', 'String', - CRM_Core_DAO::$_nullObject - ); + $membershipType = CRM_Utils_Request::retrieve('type', 'String'); if ($membershipType) { $this->_formValues['membership_type_id'] = array($membershipType); $this->_defaults['membership_type_id'] = array($membershipType); } - $cid = CRM_Utils_Request::retrieve('cid', 'Positive', - CRM_Core_DAO::$_nullObject - ); + $cid = CRM_Utils_Request::retrieve('cid', 'Positive'); if ($cid) { $cid = CRM_Utils_Type::escape($cid, 'Integer'); @@ -330,32 +324,24 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { } } - $fromDate = CRM_Utils_Request::retrieve('start', 'Date', - CRM_Core_DAO::$_nullObject - ); + $fromDate = CRM_Utils_Request::retrieve('start', 'Date'); if ($fromDate) { list($date) = CRM_Utils_Date::setDateDefaults($fromDate); $this->_formValues['member_start_date_low'] = $this->_defaults['member_start_date_low'] = $date; } - $toDate = CRM_Utils_Request::retrieve('end', 'Date', - CRM_Core_DAO::$_nullObject - ); + $toDate = CRM_Utils_Request::retrieve('end', 'Date'); if ($toDate) { list($date) = CRM_Utils_Date::setDateDefaults($toDate); $this->_formValues['member_start_date_high'] = $this->_defaults['member_start_date_high'] = $date; } - $joinDate = CRM_Utils_Request::retrieve('join', 'Date', - CRM_Core_DAO::$_nullObject - ); + $joinDate = CRM_Utils_Request::retrieve('join', 'Date'); if ($joinDate) { list($date) = CRM_Utils_Date::setDateDefaults($joinDate); $this->_formValues['member_join_date_low'] = $this->_defaults['member_join_date_low'] = $date; } - $joinEndDate = CRM_Utils_Request::retrieve('joinEnd', 'Date', - CRM_Core_DAO::$_nullObject - ); + $joinEndDate = CRM_Utils_Request::retrieve('joinEnd', 'Date'); if ($joinEndDate) { list($date) = CRM_Utils_Date::setDateDefaults($joinEndDate); $this->_formValues['member_join_date_high'] = $this->_defaults['member_join_date_high'] = $date; diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index acff6b4f14..9a2f41c486 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -369,17 +369,13 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { $this->_defaults['pledge_status_id'] = $statuses; } - $pledgeFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', - CRM_Core_DAO::$_nullObject - ); + $pledgeFromDate = CRM_Utils_Request::retrieve('pstart', 'Date'); if ($pledgeFromDate) { list($date) = CRM_Utils_Date::setDateDefaults($pledgeFromDate); $this->_formValues['pledge_create_date_low'] = $this->_defaults['pledge_create_date_low'] = $date; } - $pledgeToDate = CRM_Utils_Request::retrieve('pend', 'Date', - CRM_Core_DAO::$_nullObject - ); + $pledgeToDate = CRM_Utils_Request::retrieve('pend', 'Date'); if ($pledgeToDate) { list($date) = CRM_Utils_Date::setDateDefaults($pledgeToDate); $this->_formValues['pledge_create_date_high'] = $this->_defaults['pledge_create_date_high'] = $date; diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index b757cc6d14..781761b46d 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -524,19 +524,9 @@ class CRM_Report_Form extends CRM_Core_Form { * @throws \Exception */ public function preProcessCommon() { - $this->_force - = CRM_Utils_Request::retrieve( - 'force', - 'Boolean', - CRM_Core_DAO::$_nullObject - ); + $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean'); - $this->_dashBoardRowCount - = CRM_Utils_Request::retrieve( - 'rowCount', - 'Integer', - CRM_Core_DAO::$_nullObject - ); + $this->_dashBoardRowCount = CRM_Utils_Request::retrieve('rowCount', 'Integer'); $this->_section = CRM_Utils_Request::retrieve('section', 'Integer'); diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 45cf6658e3..b762478c61 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -317,7 +317,7 @@ abstract class CRM_Utils_Hook { * based on op. pre-hooks return a boolean or * an error message which aborts the operation */ - public static function post($op, $objectName, $objectId, &$objectRef) { + public static function post($op, $objectName, $objectId, &$objectRef = NULL) { $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef); \Civi::service('dispatcher')->dispatch("hook_civicrm_post", $event); \Civi::service('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event); diff --git a/api/v3/Generic/Setvalue.php b/api/v3/Generic/Setvalue.php index ee53e093dd..21b68381f2 100644 --- a/api/v3/Generic/Setvalue.php +++ b/api/v3/Generic/Setvalue.php @@ -143,7 +143,7 @@ function civicrm_api3_generic_setValue($apiRequest) { $params[$field] = ''; } CRM_Core_BAO_CustomValueTable::setValues($params); - CRM_Utils_Hook::post('edit', $entity, $id, CRM_Core_DAO::$_nullObject); + CRM_Utils_Hook::post('edit', $entity, $id); } // Core fields elseif (CRM_Core_DAO::setFieldValue($dao_name, $id, $field, $params[$field])) { diff --git a/api/v3/utils.php b/api/v3/utils.php index 76952c0cd9..f84198e7c5 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1531,7 +1531,7 @@ function _civicrm_api3_custom_data_get(&$returnArray, $checkPermission, $entity, TRUE, $checkPermission ); - $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject); + $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1); $customValues = array(); CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $customValues); $fieldInfo = array(); diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php index 300012dfff..ead636074f 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php @@ -90,7 +90,7 @@ class CRM_Contribute_BAO_ContributionRecurTest extends CiviUnitTestCase { */ public function testCancelRecur() { $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params); - CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($contributionRecur['id'], CRM_Core_DAO::$_nullObject); + CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($contributionRecur['id'], NULL); } /** diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php index 8154c06c7c..18434fe9f4 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -57,8 +57,6 @@ class CRM_Contribute_Form_Task_InvoiceTest extends CiviUnitTestCase { 'forPage' => 1, ); - $form = new CRM_Contribute_Form_Task_Invoice(); - $this->_individualId = $this->individualCreate(); $contributionParams = array( 'contact_id' => $this->_individualId, @@ -78,7 +76,7 @@ class CRM_Contribute_Form_Task_InvoiceTest extends CiviUnitTestCase { $contactIds[] = $this->_individualId; foreach ($contributionIDs as $contributionID) { - $invoiceHTML[current($contributionID)] = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID, $params, $contactIds, $form); + $invoiceHTML[current($contributionID)] = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID, $params, $contactIds); } $this->assertNotContains('Due Date', $invoiceHTML[$result['id']]); -- 2.25.1