When _node_reference_options() does execute node_reference_potential_references(), it doesn't pass in any options, wich means that the defaults are used.

The default set limit to 0, which means no limitation at all.

If you have ~400k nodes, like we do, then it explodes.

The attached patch sets the default limit to 10 instead, not sure if a different value should be chosen, but there needs to be something.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
Berdir’s picture

Status: Needs review » Needs work

The patch needs more work, the current logic limits select fields to 10 entries as they don't pass a limit option explicitly.

grendzy’s picture

Priority: Normal » Critical
Status: Needs work » Needs review
FileSize
642 bytes

I think this is critical, since it causes fatal out of memory errors.

For me, the solution was to remove the code that modifies display_options['pager']['options']['items_per_page']. What was happening is the default (0) was clobbering any value set in the view itself. This also fixes #1330494: Node Reference field doesn't recognize "Items to display:Display a specified number of items".

Am I missing something? Is there a condition where items_per_page needs to be set by the module?

wuinfo - Bill Wu’s picture

I think we need some kind of special widget to meet the requirement or just use the auto complete text field. #3's patch limited the available options and did not solve the problem of referencing by node type.

jenlampton’s picture

Title: _node_reference_options() does not limit the number of results » Add a limit to the number of results in _node_reference_options().
Issue summary: View changes
FileSize
1.55 KB

This patch combined the two approaches above, but adds a limit for user references as well as node references. I also thought 10 was too few items, so changed the initial default to 25.

igorgoncalves’s picture

Thanks a lot... i spent so much time trying to understand why my views number of items doesnt work at all

renatog’s picture

Assigned: Unassigned » renatog
Status: Needs review » Reviewed & tested by the community
Issue tags: +ciandt-contrib
FileSize
36.52 KB
25.18 KB

Hi people.

I applied the patch and works good for me.

Before:

After:

Thank you very much.

  • RenatoG committed 909407d on 7.x-2.x authored by jenlampton
    Issue #1345920 by jenlampton, grendzy, RenatoG, wuinfo, igormoreira: Add...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Fixed.

Commited in dev branch.

Thank you very much for contribution people.

Good Work.

Regards.

Status: Fixed » Closed (fixed)

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

liquidcms’s picture

Am i reading this correct? The node/user ref fields used to not limit the number of items listed in a select list? And now this has been hard coded to limit to 25?

But this has now broken my site as i need more items there. Does it not make more sense to have this as an option?

ShaunLaws’s picture

I agreed with liquidcms. I have a site that makes heavy use of node and user references with the chosen widget, and when I installed the dev version the site's users could only see 25 options, and weren't able to select options outside of that set of 25.

Geater’s picture

So despite the fact that liquidcms and ShaunLaws raised serious issues with this "fix", 3 years later it gets slipped into the production release.

We manage a website that has node references running into the hundreds (which isn't an unreasonable number), and after a few content changes things came crashing down (the node forms are busy and you don't expect to have to monitor the select box each time you make an edit). Time was wasted and clients were affected.

I think this change should be rolled back, or at the very least expose an option for the widget to specify a custom limit. 25 is utterly arbitrary.

dbrouard’s picture

Agree with the previous post, this change breaks the systems.

With this limit at 25, if you edit a node with an option out of the first 25, the field is empty and you may lose information if the user saves.

At least it should be configurable and with default "0" to assure the system is not broken and no information is lost.

varkenshand’s picture

I changed the coded limit from 25 to 2000, this is sufficient in my case while waiting for a fix

yallara’s picture

Is it really the case that one must edit the source to have more than 25 options displayed? If so, I'm stunned that anyone thought that was in any way reasonable. If not, the documentation should explain how to change the limit to a more realistic number.

varkenshand’s picture

2.4 is out and the problem persists

awolfey’s picture

Confirming this is a problem. It would be good to have an option in the field config to limit these, but the default should be to show ALL options.

tj2653’s picture

Agree with awolfey. Let people who want to set a limit set it through an option, but arbitrarily limiting everyone to 25 makes no sense. I just spent hours trying to figure out why my node with 100+ references, which had worked flawlessly for years, suddenly gave me "this post can't be referenced" errors when I tried to save it: https://www.drupal.org/project/references/issues/3279888#comment-14584580

Even when I didn't update any values and just hit Save, I'd still get errors. And there was no clarity on why the errors were happening....all posts I can find about "this post can't be referenced" deal with caching or issues with the view. This will cause lots of people grief when they get around to updating this module.

litzastark’s picture

FileSize
517 bytes

I just ran into the same issue, which broke our existing nodes with more than 25 references in a field. I was able to quickly fix that scenario by setting "limit" to the # of submitted ids - attaching the very simple patch here. There may be other places where the limit still causes problems, but this is a start.

pikadroo’s picture

Thanks for the solution there #3 you completely broke my site. What a noob fix, how did this get into a Drupal update? How does Drupal allow things to go out there that WILL CLEARLY break a site. makes me sick.

Drew

varkenshand’s picture

I share the frustration, why is there no working release for this module? It should not have been released in the first place

capellic’s picture

Can you revert this commit? Broke our site. If someone has an issue with too many nodes loading into their field widget, they should use a View to build their widget -- this is existing functionality.

tawellman’s picture

Why would you limit it to 25? Pain in the....!!! Please change it!