From: Tim Otten Date: Tue, 10 Jun 2014 02:30:45 +0000 (-0700) Subject: CRM-14765 - FullText - Split prepareQueries / runQueries X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=180ed6f533d58aae82f2e2757b8505ddd6ff95a0;p=civicrm-core.git CRM-14765 - FullText - Split prepareQueries / runQueries Without this patch, changing the signature of runQueries() requires changing the every fillTempTables() *and* every fillFooIDs(). With this patch, we can change the signature of runQueries() without changing evey fillFooID() function. --- diff --git a/CRM/Contact/Form/Search/Custom/FullText/Activity.php b/CRM/Contact/Form/Search/Custom/FullText/Activity.php index 7b981c46ba..5d38329740 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Activity.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Activity.php @@ -46,16 +46,18 @@ class CRM_Contact_Form_Search_Custom_FullText_Activity extends CRM_Contact_Form_ * {@inheritdoc} */ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) { - $count = $this->fillActivityIDs($queryText, $entityIDTableName, $queryLimit); + $queries = $this->prepareQueries($queryText, $entityIDTableName); + $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit); $this->moveActivityIDs($entityIDTableName, $toTable, $detailLimit); - return $count; + return $result; } /** * @param string $queryText - * @return int the total number of matches + * @param string $entityIDTableName + * @return array list tables/queries (for runQueries) */ - function fillActivityIDs($queryText, $entityIDTableName, $limit) { + function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer $contactSQL = array(); @@ -105,7 +107,7 @@ AND (ca.is_deleted = 0 OR ca.is_deleted IS NULL) ); $this->fillCustomInfo($tables, "( 'Activity' )"); - return $this->runQueries($queryText, $tables, $entityIDTableName, $limit); + return $tables;; } public function moveActivityIDs($fromTable, $toTable, $limit) { diff --git a/CRM/Contact/Form/Search/Custom/FullText/Case.php b/CRM/Contact/Form/Search/Custom/FullText/Case.php index 98fc5bdeca..ef2f37009f 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Case.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Case.php @@ -47,16 +47,18 @@ class CRM_Contact_Form_Search_Custom_FullText_Case extends CRM_Contact_Form_Sear * {@inheritdoc} */ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) { - $count = $this->fillCaseIDs($queryText, $entityIDTableName, $queryLimit); + $queries = $this->prepareQueries($queryText, $entityIDTableName); + $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit); $this->moveCaseIDs($entityIDTableName, $toTable, $detailLimit); - return $count; + return $result; } /** * @param string $queryText - * @return int the total number of matches + * @param string $entityIDTableName + * @return array list tables/queries (for runQueries) */ - function fillCaseIDs($queryText, $entityIDTableName, $limit) { + function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer $contactSQL = array(); @@ -96,7 +98,7 @@ GROUP BY et.entity_id 'sql' => $contactSQL, ); - return $this->runQueries($queryText, $tables, $entityIDTableName, $limit); + return $tables; } public function moveCaseIDs($fromTable, $toTable, $limit) { diff --git a/CRM/Contact/Form/Search/Custom/FullText/Contact.php b/CRM/Contact/Form/Search/Custom/FullText/Contact.php index 0eb806b026..b484ec2052 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Contact.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Contact.php @@ -46,16 +46,18 @@ class CRM_Contact_Form_Search_Custom_FullText_Contact extends CRM_Contact_Form_S * {@inheritdoc} */ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) { - $count = $this->fillContactIDs($queryText, $entityIDTableName, $queryLimit); + $queries = $this->prepareQueries($queryText, $entityIDTableName); + $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit); $this->moveContactIDs($entityIDTableName, $toTable, $detailLimit); - return $count; + return $result; } /** * @param string $queryText - * @return int the total number of matches + * @param string $entityIDTableName + * @return array list tables/queries (for runQueries) */ - function fillContactIDs($queryText, $entityIDTableName, $limit) { + function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer $contactSQL = array(); @@ -117,7 +119,7 @@ GROUP BY et.entity_id "( 'Contact', 'Individual', 'Organization', 'Household' )" ); - return $this->runQueries($queryText, $tables, $entityIDTableName, $limit); + return $tables; } public function moveContactIDs($fromTable, $toTable, $limit) { diff --git a/CRM/Contact/Form/Search/Custom/FullText/Contribution.php b/CRM/Contact/Form/Search/Custom/FullText/Contribution.php index b4fad6dd7e..534f3e3e75 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Contribution.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Contribution.php @@ -48,18 +48,20 @@ class CRM_Contact_Form_Search_Custom_FullText_Contribution extends CRM_Contact_F * {@inheritdoc} */ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) { - $count = $this->fillContributionIDs($queryText, $entityIDTableName, $queryLimit); + $queries = $this->prepareQueries($queryText, $entityIDTableName); + $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit); $this->moveContributionIDs($entityIDTableName, $toTable, $detailLimit); - return $count; + return $result; } /** * get contribution ids in entity tables. * * @param string $queryText - * @return int the total number of matches + * @param string $entityIDTableName + * @return array list tables/queries (for runQueries) */ - function fillContributionIDs($queryText, $entityIDTableName, $limit) { + function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer $contactSQL = array(); @@ -94,7 +96,7 @@ WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_n // get the custom data info $this->fillCustomInfo($tables, "( 'Contribution' )"); - return $this->runQueries($queryText, $tables, $entityIDTableName, $limit); + return $tables; } public function moveContributionIDs($fromTable, $toTable, $limit) { diff --git a/CRM/Contact/Form/Search/Custom/FullText/Membership.php b/CRM/Contact/Form/Search/Custom/FullText/Membership.php index 2ec54eeb5d..9be1518ae1 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Membership.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Membership.php @@ -48,18 +48,20 @@ class CRM_Contact_Form_Search_Custom_FullText_Membership extends CRM_Contact_For * {@inheritdoc} */ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) { - $count = $this->fillMembershipIDs($queryText, $entityIDTableName, $queryLimit); + $queries = $this->prepareQueries($queryText, $entityIDTableName); + $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit); $this->moveMembershipIDs($entityIDTableName, $toTable, $detailLimit); - return $count; + return $result; } /** * get membership ids in entity tables. * * @param string $queryText - * @return int the total number of matches + * @param string $entityIDTableName + * @return array list tables/queries (for runQueries) */ - function fillMembershipIDs($queryText, $entityIDTableName, $limit) { + function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer $contactSQL = array(); @@ -79,7 +81,7 @@ WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_n // get the custom data info $this->fillCustomInfo($tables, "( 'Membership' )"); - return $this->runQueries($queryText, $tables, $entityIDTableName, $limit); + return $tables; } public function moveMembershipIDs($fromTable, $toTable, $limit) { diff --git a/CRM/Contact/Form/Search/Custom/FullText/Participant.php b/CRM/Contact/Form/Search/Custom/FullText/Participant.php index 5af52f39bb..79b7f575dc 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Participant.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Participant.php @@ -48,18 +48,20 @@ class CRM_Contact_Form_Search_Custom_FullText_Participant extends CRM_Contact_Fo * {@inheritdoc} */ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLimit, $detailLimit) { - $count = $this->fillParticipantIDs($queryText, $entityIDTableName, $queryLimit); + $queries = $this->prepareQueries($queryText, $entityIDTableName); + $result = $this->runQueries($queryText, $queries, $entityIDTableName, $queryLimit); $this->moveParticipantIDs($entityIDTableName, $toTable, $detailLimit); - return $count; + return $result; } /** * get participant ids in entity tables. * * @param string $queryText - * @return int the total number of matches + * @param string $entityIDTableName + * @return array list tables/queries (for runQueries) */ - function fillParticipantIDs($queryText, $entityIDTableName, $limit) { + function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer $contactSQL = array(); @@ -91,7 +93,7 @@ WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_n // get the custom data info $this->fillCustomInfo($tables, "( 'Participant' )"); - return $this->runQueries($queryText, $tables, $entityIDTableName, $limit); + return $tables; } public function moveParticipantIDs($fromTable, $toTable, $limit) {