Merge pull request #17938 from seamuslee001/ref_fix_financial_account
[civicrm-core.git] / CRM / Contact / Form / Task.php
index b478fb486799a1a2112338fdef9c504a1cdcac56..2f7695dc7db1b0d953f9111962ddf71ab59ff658 100644 (file)
@@ -86,8 +86,6 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
     $form->_contactIds = [];
     $form->_contactTypes = [];
 
-    $useTable = (CRM_Utils_System::getClassName($form->controller->getStateMachine()) == 'CRM_Export_StateMachine_Standalone');
-
     $isStandAlone = in_array('task', $form->urlPath) || in_array('standalone', $form->urlPath);
     if ($isStandAlone) {
       list($form->_task, $title) = CRM_Contact_Task::getTaskAndTitleByClass(get_class($form));
@@ -137,13 +135,6 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
     $crmContactTaskTasks = CRM_Contact_Task::taskTitles();
     $form->assign('taskName', CRM_Utils_Array::value($form->_task, $crmContactTaskTasks));
 
-    if ($useTable) {
-      $tempTable = CRM_Utils_SQL_TempTable::build()->setCategory('tskact')->setDurable()->setId($qfKey);
-      $form->_componentTable = $tempTable->getName();
-      $tempTable->drop();
-      $tempTable->createWithColumns('contact_id int primary key');
-    }
-
     // all contacts or action = save a search
     if ((CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_all') ||
       ($form->_task == CRM_Contact_Task::SAVE_SEARCH)
@@ -151,34 +142,10 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
       // since we don't store all contacts in prevnextcache, when user selects "all" use query to retrieve contacts
       // rather than prevnext cache table for most of the task actions except export where we rebuild query to fetch
       // final result set
-      if ($useTable) {
-        $allCids = Civi::service('prevnext')->getSelection($cacheKey, "getall");
-      }
-      else {
-        $allCids[$cacheKey] = self::getContactIds($form);
-      }
+      $allCids[$cacheKey] = self::getContactIds($form);
 
       $form->_contactIds = [];
-      if ($useTable) {
-        $count = 0;
-        $insertString = [];
-        foreach ($allCids[$cacheKey] as $cid => $ignore) {
-          $count++;
-          $insertString[] = " ( {$cid} ) ";
-          if ($count % 200 == 0) {
-            $string = implode(',', $insertString);
-            $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES $string";
-            CRM_Core_DAO::executeQuery($sql);
-            $insertString = [];
-          }
-        }
-        if (!empty($insertString)) {
-          $string = implode(',', $insertString);
-          $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES $string";
-          CRM_Core_DAO::executeQuery($sql);
-        }
-      }
-      elseif (empty($form->_contactIds)) {
+      if (empty($form->_contactIds)) {
         // filter duplicates here
         // CRM-7058
         // might be better to do this in the query, but that logic is a bit complex
@@ -201,13 +168,7 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
         // need to perform action on only selected contacts
         foreach (self::$_searchFormValues as $name => $value) {
           if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
-            $contactID = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
-            if ($useTable) {
-              $insertString[] = " ( {$contactID} ) ";
-            }
-            else {
-              $form->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
-            }
+            $form->_contactIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
           }
         }
       }
@@ -215,12 +176,7 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
         // fetching selected contact ids of passed cache key
         $selectedCids = Civi::service('prevnext')->getSelection($cacheKey);
         foreach ($selectedCids[$cacheKey] as $selectedCid => $ignore) {
-          if ($useTable) {
-            $insertString[] = " ( {$selectedCid} ) ";
-          }
-          else {
-            $form->_contactIds[] = $selectedCid;
-          }
+          $form->_contactIds[] = $selectedCid;
         }
       }
 
@@ -378,7 +334,7 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
   /**
    * Replace ids of household members in $this->_contactIds with the id of their household.
    *
-   * CRM-8338
+   * @see https://issues.civicrm.org/jira/browse/CRM-8338
    */
   public function mergeContactIdsByHousehold() {
     if (empty($this->_contactIds)) {