Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.148
diff -u -p -r1.1.2.12.2.148 apachesolr.module
--- apachesolr.module	19 Jun 2009 20:31:58 -0000	1.1.2.12.2.148
+++ apachesolr.module	29 Jun 2009 17:25:06 -0000
@@ -569,7 +569,7 @@ function apachesolr_block($op = 'list', 
         $sorts = $query->get_available_sorts();
 
         $solrsorts = array();
-        $sort_parameter = isset($_GET['solrsort']) ? check_plain($_GET['solrsort']) : FALSE;
+        $sort_parameter = $query->get_solrsort();
         foreach (explode(',', $sort_parameter) as $solrsort) {
           $parts = explode(' ', $solrsort);
           if (!empty($parts[0]) && !empty($parts[1])) {
@@ -1477,7 +1477,12 @@ interface Drupal_Solr_Query_Interface {
    * @param string raw string to set the sort to
    */
   function set_solrsort($sortstring);
-  
+
+  /**
+   * Get the solrsort.
+   */
+  function get_solrsort();
+
   /**
    * Return an array of all filters.
    */
Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.104
diff -u -p -r1.1.2.6.2.104 apachesolr_search.module
--- apachesolr_search.module	22 Jun 2009 19:13:13 -0000	1.1.2.6.2.104
+++ apachesolr_search.module	29 Jun 2009 17:25:07 -0000
@@ -76,8 +76,12 @@ function apachesolr_search_menu_alter(&$
       unset($menu['search/apachesolr_search/%menu_tail']['title callback'], $menu['search/apachesolr_search/%menu_tail']['title arguments']);
       $menu['search/apachesolr_search/%menu_tail']['title'] = 'Content';
     }
-    if (isset($menu['search'])) {
-      $menu['search']['page arguments'] = array('apachesolr_search');
+  }
+  if (variable_get('apachesolr_search_taxonomy_links', 0)) {
+    if (isset($menu['taxonomy/term/%'])) {
+      $menu['taxonomy/term/%']['page callback'] = 'apachesolr_search_taxonomy_term_page';
+      $menu['taxonomy/term/%']['file path'] = drupal_get_path('module', 'apachesolr_search');
+      $menu['taxonomy/term/%']['file'] = 'apachesolr.taxonomy.inc';
     }
   }
 }
@@ -220,7 +224,7 @@ function apachesolr_search_execute($keys
   if (!$query) {
     return array();
   }
-  
+
   if ('' == $keys) {
     // Move the fq params to the q.alt for better performance.
     $params['q.alt'] = implode(' ', $params['fq']);
@@ -763,24 +767,33 @@ function apachesolr_search_search_box_fo
  * This adds spelling suggestions, retain filters to the search form.
  */
 function apachesolr_search_form_search_form_alter(&$form, $form_state) {
-
   if ($form['module']['#value'] == 'apachesolr_search') {
-    $filters = isset($_REQUEST['filters']) ? trim($_REQUEST['filters']) : '';
+    $form['#submit'] = array('apachesolr_search_form_search_submit');
+    // No other modification make sense unless a query is active.
+    // Note - this means that the query must always be run before
+    // calling drupal_get_form('search_form').
+    $apachesolr_has_searched = apachesolr_has_searched();
+
+    $querystring = '';
+    if ($apachesolr_has_searched) {
+      $query = apachesolr_current_query();
+      $querystring = $query->get_url_querystring();
+    }
+
     $form['basic']['apachesolr_search']['#tree'] = TRUE;
-    if ($filters) {
+    $form['basic']['apachesolr_search']['querystring'] = array(
+      '#type' => 'hidden',
+      '#default_value' => $querystring,
+    );
+    if ($querystring || isset($form_state['post']['apachesolr_search']['retain-filters'])) {
       $form['basic']['apachesolr_search']['retain-filters'] = array(
         '#type' => 'checkbox',
         '#title' => t('Retain current filters'),
-        '#default_value' => !empty($_GET['retain-filters']), 
+        '#default_value' => (int) isset($_GET['retain-filters']), 
       );
     }
-    $form['filters'] = array(
-      '#type' => 'hidden',
-      '#default_value' => $filters,
-    );
 
-    $form['#submit'] = array('apachesolr_search_form_search_submit');
-    if (variable_get('apachesolr_search_spellcheck', FALSE) && apachesolr_has_searched() && ($response = apachesolr_static_response_cache())) {
+    if (variable_get('apachesolr_search_spellcheck', FALSE) && $apachesolr_has_searched && ($response = apachesolr_static_response_cache())) {
       //Get spellchecker suggestions into an array.
       $suggestions = get_object_vars($response->spellcheck->suggestions);
   
@@ -813,16 +826,16 @@ function apachesolr_search_form_search_f
 function apachesolr_search_form_search_submit($form, &$form_state) {
   $fv = $form_state['values'];
   $keys = $fv['processed_keys'];
-  $query = '';
+  $querystring = '';
   $base = 'search/'. $fv['module'] . '/';
   if (variable_get('clean_url', '0')) {
     $keys = str_replace('+', '%2B', $keys);
   }
-  if (!empty($fv['apachesolr_search']['retain-filters']) && $fv['filters']) {
-    $query = 'filters=' . rawurlencode($fv['filters']) . '&retain-filters=1';
+  if (!empty($fv['apachesolr_search']['retain-filters']) && $fv['apachesolr_search']['querystring']) {
+    $querystring = $fv['apachesolr_search']['querystring'] . '&retain-filters';
   }
-  $form_state['redirect'] = array($base . $keys, $query);
-  if ($keys == '' && $query == '') {
+  $form_state['redirect'] = array($base . $keys, $querystring);
+  if ($keys == '' && $querystring == '') {
     form_set_error('keys', t('Please enter some keywords.'));
   }
 }
@@ -844,6 +857,18 @@ function apachesolr_search_form_apacheso
     '#type' => 'value',
     '#value' => variable_get('apachesolr_search_make_default', 0),
   );
+  $form['advanced']['apachesolr_search_taxonomy_links'] = array(
+    '#type' => 'radios',
+    '#title' => t('Use Apache Solr for taxonomy links'),
+    '#default_value' => variable_get('apachesolr_search_taxonomy_links', 0),
+    '#description' => t('Note: Vocabularies that need this behavior need to be checked off on the <a href="@enabled_filters_url">enabled filters</a> settings page', array('@enabled_filters_url' => url('settings/apachesolr/enabled-filters'))),
+    '#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
+  );
+  $form['advanced']['apachesolr_search_taxonomy_previous'] = array(
+    '#type' => 'value',
+    '#value' => variable_get('apachesolr_search_taxonomy_links', 0),
+  );
+
   $form['apachesolr_search_spellcheck'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable spellchecker and suggestions'),
@@ -865,7 +890,9 @@ function apachesolr_search_form_apacheso
  * @see apachesolr_search_form_apachesolr_settings_alter()
  */
 function apachesolr_search_make_default_submit($form, &$form_state) {
-  if ($form_state['values']['apachesolr_search_default_previous'] != variable_get('apachesolr_search_make_default', 0)) {
+  // We use variable_get() instead of the form values so as to also handle reset to defaults.
+  if ($form_state['values']['apachesolr_search_default_previous'] != variable_get('apachesolr_search_make_default', 0) ||
+      $form_state['values']['apachesolr_search_taxonomy_previous'] != variable_get('apachesolr_search_make_default', 0)) {
     // Take account of path changes
     menu_rebuild();
   }
Index: Solr_Base_Query.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/Solr_Base_Query.php,v
retrieving revision 1.1.4.36
diff -u -p -r1.1.4.36 Solr_Base_Query.php
--- Solr_Base_Query.php	18 Jun 2009 20:45:36 -0000	1.1.4.36
+++ Solr_Base_Query.php	29 Jun 2009 17:25:07 -0000
@@ -111,7 +111,7 @@ class Solr_Base_Query implements Drupal_
    *   may come from search_get_keys().
    *
    * @param $filterstring
-   *   Key and value pairs that are applied as a filter query.
+   *   Key and value pairs that are applied as filter queries.
    *
    * @param $sortstring
    *   Visible string telling solr how to sort - added to output querystring.
@@ -133,7 +133,7 @@ class Solr_Base_Query implements Drupal_
   function __clone() {
     $this->id = ++self::$idCount;
   }
-
+  
   public function add_filter($field, $value, $exclude = FALSE) {
     $this->fields[] = array('#exclude' => $exclude, '#name' => $field, '#value' => trim($value));
   }
@@ -237,6 +237,10 @@ class Solr_Base_Query implements Drupal_
     $this->solrsort = trim($sortstring);
   }
 
+  public function get_solrsort() {
+    return $this->solrsort;
+  }
+
   public function get_available_sorts() {
     return $this->available_sorts;
   }
