Discovered an oddity that seems inherent in the node_reference.module 7.x-2.1
. It is a rather specific use-case, so I can see why it might not have come up frequently before. Just wondering if anyone has any work around ideas, either that or I'll document my findings if I reach a solution.
How to reproduce the issue:
- Create a reference list view, and use it to power an autocomplete field.
- Create another view and attempt to use the created field as a filter.
- Everything will work fine, unless that field has a large number of values. The field I'm using has upwards of 90,000 items.
- This is because the views filter UI attempts to render all possible values as a checkbox list.
The reason it trips up is because:
function _node_reference_options($field, $flat = TRUE) {
Goes on to call:
$references = node_reference_potential_references($field);
Without any options. Which leads to:
references_potential_references_view(
$entity_type, $view_name, $display_name, $args, $options);
Being called without any options, and it seems this code does not read the pager settings to get its limit
value. Instead it relies on $options['limit']
.
$limit = !empty($options['limit']) ? $options['limit'] : 0;
$view->display_handler->set_option('pager', array(
'type' => 'some', 'options' => array('items_per_page' => $limit)));
I'm not sure which bit of the code is at fault — i.e. who should definite a limit, or read the pager settings — but there definitely needs to be a defined limit and not 0
. Especially when dealing with so many possible values. Setting a limit specifically for the pager in Views UI does not work as it is circumvented.
Currently I can't even get to edit my view with the filter specified, unless I hack the references module to pass:
$references = node_reference_potential_references($field, array('limit' => 10));
I'm only adding this as a filter so I can state that the field isn't empty. I could just leave the hack in until I've set the filter to a state that doesn't read the values. However this feels rather unsafe — especially if someone else was to take over the code at a future point.