PHP Fatal error: Call to undefined method can_expose() in views/plugins/views_plugin_display.inc on line 1872
This error happens when trying to save the settings form for certain filters. It happened to us with User name filters and Date filters.
This is the original problem, I think. The following code found in views_plugin_display.inc:
/**
* Check if the provided identifier is unique.
*/
function is_identifier_unique($id, $identifier) {
foreach (views_object_types() as $type => $info) {
foreach ($this->get_handlers($type) as $key => $handler) {
if ($handler->can_expose() && $handler->is_exposed()) {
if ($id != $key && $identifier == $handler->options['expose']['identifier']) {
return FALSE;
}
}
}
}
return TRUE;
}
views_object_types() is defined in includes/view.inc and looks like this:
function views_object_types() {
static $retval = NULL;
// statically cache this so t() doesn't run a bajillion times.
if (!isset($retval)) {
$retval = array(
'field' => array(
'title' => t('Fields'), // title
'ltitle' => t('fields'), // lowercase title for mid-sentence
'stitle' => t('Field'), // singular title
'lstitle' => t('field'), // singular lowercase title for mid sentence
'plural' => 'fields',
),
'argument' => array(
'title' => t('Arguments'),
'ltitle' => t('arguments'),
'stitle' => t('Argument'),
'lstitle' => t('Argument'),
'plural' => 'arguments',
),
'sort' => array(
'title' => t('Sort criteria'),
'ltitle' => t('sort criteria'),
'stitle' => t('Sort criterion'),
'lstitle' => t('sort criterion'),
'plural' => 'sorts',
),
'filter' => array(
'title' => t('Filters'),
'ltitle' => t('filters'),
'stitle' => t('Filter'),
'lstitle' => t('filter'),
'plural' => 'filters',
'options' => 'views_ui_config_filters_form',
),
'relationship' => array(
'title' => t('Relationships'),
'ltitle' => t('relationships'),
'stitle' => t('Relationship'),
'lstitle' => t('Relationship'),
'plural' => 'relationships',
),
);
}
return $retval;
}
This means the method is_identifier_unique() tries to invoke can_expose() for all handlers of all these types. However, can_expose() is not defined for all handlers.
I have added function can_expose() { return FALSE; } to views_handler class definition temporarily. Though, I'm not 100% sure this is correct.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | views2-bug-623580.patch | 634 bytes | dagmar |
Comments
Comment #1
markus_petrux commentedAdditional testing, and it seems to happen every time one tries to save an exposed filter. The visible symthom is that an error similar to the following is reported by AHAH handler:
Adding the following to
views_handlerclass defined inincludes/handlers.incComment #2
dagmarWell, in fact, the problem is that #458140: Allow any handler to use exposed form was only committed for 3.x branch, and function can_expose() is not present in handlers.inc for 2.x version. But #363516: No validation to ensure exposed filter identifiers are unique was committed to 2.x and 3.x
As markus_petrus said, adding this function to views_handler solve the problem. Here is a patch.
Comment #3
dawehnerThis makes 100% sense. A RTBC from me.
Comment #4
merlinofchaos commentedMakes sense. Committed. Only with some extra spaces inside the { }