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.

CommentFileSizeAuthor
#3 entity_load.patch542 bytesfago
default-entities.patch770 bytesklausi
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klausi’s picture

Status: Needs review » Active

Oh, 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?

fago’s picture

Title: Default entities do not load » DX: entity_load() defaults are useless
Project: Entity API » Drupal core
Version: 7.x-1.x-dev » 7.x-dev
Component: Entity API » base system
Status: Active » Needs review

Yep, 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 like entity_load('entity_type').

Patch attached.

fago’s picture

FileSize
542 bytes
moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

makes sense

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

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