On line 48 of date_views_filter_handler_simple.inc, we have the following function:

**
   * Helper function to find a default value.
   */
  function date_default_value($prefix, $options = NULL) {
    $default_date = '';
    if (empty($options)) {
      $options = $this->options;
    }
    // If this is a remembered value, use the value from the SESSION.
    if (!empty($this->options['expose']['remember'])) {
      $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
      if (!empty($_SESSION['views'][$this->view->name][$display_id]['date_filter'][$prefix])) {
        return $_SESSION['views'][$this->view->name][$display_id]['date_filter'][$prefix];
      }
    }

    // This is a date that needs to be constructed from options like 'now' .
    $default_option = $prefix == 'max' ? $options['default_to_date'] : $options['default_date'];
    if (!empty($default_option)) {
      str_replace('now', 'today', $default_option);
      $date = date_create($default_option, date_default_timezone_object());
      $default_date = !empty($date) ? $date->format($this->format) : '';

      // The format for our filter is in ISO format, but the widget will need it in datetime format.
      $default_date = str_replace('T', ' ', $default_date);
    }
    // This a fixed date.
    else {
      $default_date = $options['value'][$prefix];
    }
    return $default_date;
  }

All looks well, except when I went to expose a views date filter there were no errors but the date simply didn't remember. Upon closer inspection, you will see the session variable is looking for $_SESSION['views'][$this->view->name][$display_id]['date_filter'][$prefix]. However, this doesn't make sense and isn't how views STORES exposed filters, which is by the field ($_SESSION['views'][$this->view->name][FIELD_IDENTIFIER][VALUE]).

Instead, we should be looking for $_SESSION['views'][$this->view->name][$display_id][$options['id']][$prefix], which is the storage for the FIELD we are currently on. If you had multiple date filters, the same would apply. Once you switch to the code above, remembering of dates on exposed filters works perfectly.

I'm happy to submit a patch if the community agrees with my approach presented above. If anyone has a counter, let me know. Thanks!

Comments

trevorwh’s picture

Status: Active » Needs review

Marking this as needs to review so folks take a look at the approach.

trevorwh’s picture

Priority: Normal » Major

Another bump - folks, please take a look at this issue. It is major for anyone using remembered exposed filters and the date module.

podarok’s picture

Category: Bug report » Task
Issue summary: View changes
Status: Needs review » Patch (to be ported)

You should create patch in git diff format http://drupal.org/patch and upload it with Needs review status as attachement here

vijaycs85’s picture

thanks for reporting this issue @trevorwh. Can we update issue summary with steps-to-reproduce so that we can move forward with this issue please?. Would be great, if you can issue your patch as well...

dstorozhuk’s picture

Add related issue.

dstorozhuk’s picture

dstorozhuk’s picture