I get the following error when I delete a node

notice: Undefined index: base in get_query_fields() (line 578 of /public_html/sites/all/modules/date/includes/date_api_filter_handler.inc).

It is being produced by the first line in the following function

  function get_query_fields() {
    $fields = date_api_fields($this->definition['base']);
    $fields = $fields['name'];
    $this->query_fields = array();
    foreach ((array) $this->options['date_fields'] as $delta => $name) {
      if (array_key_exists($name, $fields) && $field = $fields[$name]) {
        $date_handler = new date_sql_handler();
        $date_handler->construct($field['sql_type'], date_default_timezone_name());
        $date_handler->granularity = $this->options['granularity'];
        date_views_set_timezone($date_handler, $this->view, $field);
        $this->query_fields[] = array('field' => $field, 'date_handler' => $date_handler);
      }
    }
  }

Comments

NROTC_Webmaster’s picture

I'm wondering if it is ok just to see if the base is set before trying to use it.

I just don't know if it absolutely needs a value that should be set as default or not?

This got rid of the error message and I haven't noticed any adverse side effects yet

+    if(isset($this->definition['base'])) {
      $fields = date_api_fields($this->definition['base']);
+    }
NROTC_Webmaster’s picture

Apparently we do need to add an else statement. I had to go back to version 6.x-2.1 to find something prior to what is there now.

In the change log it simply stated - Make sure $base is never empty when identifying date fields for date filter and argument.
I couldn't find a patch that changed this between the two but the else I came up with so far is

    else {
      $fields = date_api_fields($this->view->base_table);
    }
pdrake’s picture

Version: 6.x-2.8 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new667 bytes

I've combined the above recommendations into a patch for 6.x-2.x-dev.

dagmar’s picture

StatusFileSize
new2 KB

I'm having this problem too. I'm afraid the patch is not enough, there is another call to get_query_fields() in the date argument.

Also, this patch includes a $this->ensure_my_table() inside query() because it seem this issue #1034292: Unknown column error for date field in view page display is alive again.

brad.bulger’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I have been running with this latest patch and it fixes the problems.

jonathan1055’s picture

Related issues: +#1034292: Unknown column error for date field in view page display
StatusFileSize
new1.86 KB

Just had this error after upgrading to PHP5.4 and the patch fixes it. Thanks. For info, the actual code changes apply ok (with offsets) to the non-dev 6.x-2.10

The final change in the patch fails - although this is only there by accident I think, to do with differences in file-end when the patch was created.

@@ -592,4 +597,4 @@ class date_api_filter_handler extends views_handler_filter_numeric {
       }
     }
   }
-}
\ No newline at end of file
+}

Hence, here is a replacement patch with that bit removed. Still RTBC - it's just a cleaner patch.

Jonathan

cafuego’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 6.x-2.x, thanks all :-)

  • cafuego committed f2bc02e on 6.x-2.x authored by dagmar
    Issue #1411472 by pdrake, dagmar, jonathan1055, NROTC_Webmaster, brad....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.