CRM-12638 only rebuild alpha pager when needed
authorColeman Watts <coleman@civicrm.org>
Thu, 27 Jun 2013 17:42:53 +0000 (10:42 -0700)
committerColeman Watts <coleman@civicrm.org>
Tue, 23 Jul 2013 19:59:23 +0000 (12:59 -0700)
----------------------------------------
* CRM-12638: Optimize Prev/Next Cache and search interaction
  http://issues.civicrm.org/jira/browse/CRM-12638

CRM/Contact/Form/Search.php
CRM/Contact/Form/Search/Advanced.php
CRM/Contact/Form/Search/Basic.php
CRM/Contact/Form/Search/Builder.php

index 01b48d2aa5f7582eb7c6f1c19cc616f717ebc4ce..0245ec42d9f120b17c008d857814ca50f100d5c2 100644 (file)
@@ -924,15 +924,11 @@ class CRM_Contact_Form_Search extends CRM_Core_Form {
       $selector->setKey($this->controller->_key);
 
       // added the sorting  character to the form array
-      // lets recompute the aToZ bar without the sortByCharacter
-      // we need this in most cases except when just pager or sort values change, which
-      // we'll ignore for now
       $config = CRM_Core_Config::singleton();
       // do this only for contact search
       if ($setDynamic && $config->includeAlphabeticalPager) {
-        if ($this->_reset ||
-          ($this->_sortByCharacter === NULL || $this->_sortByCharacter == '')
-        ) {
+        // Don't recompute if we are just paging/sorting
+        if ($this->_reset || (empty($_GET['crmPID']) && empty($_GET['crmSID']) && !$this->_sortByCharacter)) {
           $aToZBar = CRM_Utils_PagerAToZ::getAToZBar($selector, $this->_sortByCharacter);
           $this->set('AToZBar', $aToZBar);
         }
index ea792c36c4e17816769c72cb49efbb68878b4316..0bfea752bc01e3fb0387bcf3fcf0c23ed044cece 100644 (file)
@@ -301,9 +301,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search {
     // we dont want to store the sortByCharacter in the formValue, it is more like
     // a filter on the result set
     // this filter is reset if we click on the search button
-    if ($this->_sortByCharacter !== NULL
-      && empty($_POST)
-    ) {
+    if ($this->_sortByCharacter !== NULL && empty($_POST)) {
       if (strtolower($this->_sortByCharacter) == 'all') {
         $this->_formValues['sortByCharacter'] = NULL;
       }
@@ -311,6 +309,9 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search {
         $this->_formValues['sortByCharacter'] = $this->_sortByCharacter;
       }
     }
+    else {
+      $this->_sortByCharacter = NULL;
+    }
 
     CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
 
index 88d3bae453415ddb968b6057474c96b722859fdc..e18eea976eda4cfc0bcaf5fe8814679637bf3f4f 100644 (file)
@@ -193,9 +193,7 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search {
     // we dont want to store the sortByCharacter in the formValue, it is more like
     // a filter on the result set
     // this filter is reset if we click on the search button
-    if ($this->_sortByCharacter !== NULL
-      && empty($_POST)
-    ) {
+    if ($this->_sortByCharacter !== NULL && empty($_POST)) {
       if (strtolower($this->_sortByCharacter) == 'all') {
         $this->_formValues['sortByCharacter'] = NULL;
       }
@@ -203,6 +201,9 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search {
         $this->_formValues['sortByCharacter'] = $this->_sortByCharacter;
       }
     }
+    else {
+      $this->_sortByCharacter = NULL;
+    }
 
     $this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $this->_returnProperties = &$this->returnProperties();
index b6e6bdd3532c60f8eec88c5eafa1ff02ff8bca50..8ff693a1f0e217e4f723ed7e021eabc72ee5bc4c 100644 (file)
@@ -377,6 +377,9 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search {
         $this->_formValues['sortByCharacter'] = $this->_sortByCharacter;
       }
     }
+    else {
+      $this->_sortByCharacter = NULL;
+    }
 
     $this->_params = &$this->convertFormValues($this->_formValues);
     $this->_returnProperties = &$this->returnProperties();