Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Jun 2010 at 19:24 UTC
Updated:
29 Jul 2014 at 18:53 UTC
Jump to comment: Most recent file
Comments
Comment #1
tstoecklerDefinitely not critical.
Comment #2
damien tournoud commentedNa. -1 for inconsistent APIs (I know we have some others like that lying around). The return value is always an array, so supporting either a scalar or an array as the input argument make it even more inconsistent.
By the way, this should have type-hinting, I'm not sure why this one hasn't.
Comment #3
tamasd commentedYou are right, type hinting is a better solution.
Comment #4
berdirThis actually already works because we have an empty($ids) check.
Adding the type hint breaks the tests, see also #839986: Enforce array arguments (Say good bye to Fatal error: Cannot use object of type stdClass as array errors), which I actually removed the type hint for entity_load() because it's technically an api change.
Edit: simply changing to needs review to confirm that this fails.
Comment #6
NealB-1 commentedThis version accepts a single id and should not cause any downstream ill effects.
I marked this as major, because the sooner the change is made, the greater the good it can do in terms of simplifying all the other code that invokes this function.
Comment #7
xjmThere needs to be a space between
ifand the parentheses. Reference: http://drupal.org/coding-standards#controlstructAdditionally, if we're changing the allowed values of a parameter, we need to update the function documentation to indicate that.
Finally, this is not major. I'm actually not sure this change should be made at all.
Comment #8
berdirThis is the wrong approach anyway. entity_load() needs to be renamed to entity_load_multiple(), to be consistent with all the other load functions. Sure, this will break everything, but we're allowed to do that in this stage.
Comment #9
xjmSo maybe this is a duplicate of #1160566: entity_load() is actually entity_load_multiple()?
Comment #10
tstoecklerYes, either this is won't fix for #2 or duplicate for #9. I'm going for duplicate.
Comment #11
NealB-1 commentedThanks for the pointer to http://drupal.org/node/1160566