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.
Oh noes, my default wsclient entities are gone!
This was introduced by http://github.com/fago/entity/commit/3da192f0eb68ae893078ee423c5d83f5424...
You want to check if $ids is an array AND if it actually contains something, otherwise you filter out all default entities. I suggest adding !empty(). Patch attached.
Comment | File | Size | Author |
---|---|---|---|
#3 | entity_load.patch | 542 bytes | fago |
default-entities.patch | 770 bytes | klausi | |
Comments
Comment #1
klausiOh, i should have read the commit message "Entity CRUD: fix entity loading of exportables to only add in all defaults when FALSE is passed."
Now I see that entity_load() sets $ids = array() as default, which is totally confusing. The docs say "An array of entity IDs, or FALSE to load all entities.", so a default as array() makes no sense at all. Passing an empty array will always return an empty array. Do we have a core issue for this?
Comment #2
fagoYep, I fixed a bug in the Entity CRUD API controller which erroneously added in all entities in code if an empty array was passed.
As we discussed in person, I think passing an empty array should lead to nothing being loaded. So one can filter an array of ids and pass it to entity_load() - if the array of ids is suddenly empty, still entity_load() acts as expected and does *not* load all entities.
But I agree that the default should be FALSE. Now a call using the defaults like
entity_load('entity_type')
is just silly and does nothing, but with the default FALSE you'd get all entities. I think this is a safe improvement to do even that late in the cycle, as I assume currently no one uses a does-nothing function call likeentity_load('entity_type')
.Patch attached.
Comment #3
fagoComment #4
moshe weitzman CreditAttribution: moshe weitzman commentedmakes sense
Comment #5
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.