I created a view with exposed filter 'Year' for datestamp field. When user enter non-numeric value to this field, the error appears.

Comments

karens’s picture

Status: Active » Closed (works as designed)

Why would you enter non-numeric data for the year?? Sounds to me like it is an error if you do so.

nilard’s picture

Status: Closed (works as designed) » Active

I think that is not good when guest makes casual mistake in numeric field and gets urgly PHP Fatal error instead of empty results page.

Here is my way of fixing this in date_views.inc:

function date_views_filter_handler($op, $filter, $filterinfo, &$query, $field_type = 'iso') {

< ... >

  switch ($filterinfo['type']) {
    case ('DATE'):

    < ... >

    default:
      if(!is_numeric($filter['value'])) {  // just
        $filter['value'] = 0;                 // add
      }                                          // this
      $date = $value == 'now' ? date_sql($type, "NOW()", $field_type, '') : $value;
      break;
  }

    < ... >

}
nilard’s picture

Version: 5.x-1.2 » 5.x-1.3
Status: Active » Postponed

Seems to be fixed in 1.3
But I had the same problem with filtering on partial dates as in http://drupal.org/node/124183
So I took date_views.inc from 1.2 and changed all include_once(drupal_get_path('module', 'date') .'/date.inc'); to
include_once(drupal_get_path('module', 'date_api') .'/date.inc'); within it. Now it works for me.

karens’s picture

Status: Postponed » Fixed

I don't understand marking this postponed and switching versions. That seems to have nothing to do with the original issue.

The original issue should be fixed with the latest commit -- validation has been added so no SQL is created for invalid input values.

Anonymous’s picture

Status: Fixed » Closed (fixed)