Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#20 | increase-limit.patch | 517 bytes | litzastark |
#7 | After.png | 25.18 KB | renatog |
#7 | Before.png | 36.52 KB | renatog |
#5 | references-1345920-5.patch | 1.55 KB | jenlampton |
#3 | 1345920.patch | 642 bytes | grendzy |
Comments
Comment #1
BerdirComment #2
BerdirThe patch needs more work, the current logic limits select fields to 10 entries as they don't pass a limit option explicitly.
Comment #3
grendzy CreditAttribution: grendzy commentedI 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?
Comment #4
wuinfo - Bill Wu CreditAttribution: wuinfo - Bill Wu commentedI 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.
Comment #5
jenlamptonThis 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.
Comment #6
igorgoncalves CreditAttribution: igorgoncalves commentedThanks a lot... i spent so much time trying to understand why my views number of items doesnt work at all
Comment #7
renatogHi people.
I applied the patch and works good for me.
Before:
After:
Thank you very much.
Comment #9
renatogFixed.
Commited in dev branch.
Thank you very much for contribution people.
Good Work.
Regards.
Comment #11
liquidcms CreditAttribution: liquidcms commentedAm 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?
Comment #12
ShaunLaws CreditAttribution: ShaunLaws commentedI 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.
Comment #13
Geater CreditAttribution: Geater commentedSo 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.
Comment #14
dbrouard CreditAttribution: dbrouard commentedAgree 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.
Comment #15
varkenshand CreditAttribution: varkenshand commentedI changed the coded limit from 25 to 2000, this is sufficient in my case while waiting for a fix
Comment #16
yallara CreditAttribution: yallara commentedIs 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.
Comment #17
varkenshand CreditAttribution: varkenshand commented2.4 is out and the problem persists
Comment #18
awolfey CreditAttribution: awolfey commentedConfirming 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.
Comment #19
tj2653 CreditAttribution: tj2653 commentedAgree 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.
Comment #20
litzastark CreditAttribution: litzastark commentedI 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.
Comment #21
pikadroo CreditAttribution: pikadroo commentedThanks 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
Comment #22
varkenshand CreditAttribution: varkenshand commentedI share the frustration, why is there no working release for this module? It should not have been released in the first place
Comment #23
capellicCan 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.
Comment #24
tawellman CreditAttribution: tawellman as a volunteer commentedWhy would you limit it to 25? Pain in the....!!! Please change it!