The entity_invoke() function is basically worthless. It is one line, does nothing special, *and* manages to reverse the order of arguements for normal hook calling. It could be removed with a 10-line patch, since only 6 places in core call it.

CommentFileSizeAuthor
#3 834924-remove-entity-invoke.patch7.03 KBjhodgdon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Totally +1

jhodgdon’s picture

Assigned: Unassigned » jhodgdon

I'm making a patch.

jhodgdon’s picture

Status: Active » Needs review
FileSize
7.03 KB

The code is so much cleaner without this...

chx’s picture

Status: Needs review » Reviewed & tested by the community

Well we nuked op in Drupal 7 and we reintroduced in entity_invoke which is a most useless and totally WTF-y function. So good idea to nuke it.

mikey_p’s picture

chx pointed this out that field_attach and the hook_entity_OP functions use a different order of arguments. This patch *does not* change that since we're in a code freeze, but makes the reversal of arguments slightly more clear instead of obfuscating it in a 1 line function. Major +1.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

catch’s picture

Issue tags: +API change

This is used by entity.module, not sure about elsewhere in contrib:
http://drupalcode.org/viewvc/drupal/contributions/modules/entity/entity/...

So needs to be documented/announced as an API change.

rfay’s picture

I will make the announcement.

It looks to me like I can just say

"All calls to entity_invoke('whatever') must be replaced by the equivalent module_invoke('entity_whatever', ...). If your module uses entity_invoke in your code, take a look at the simple patch in this issue to see the fix required."

True?

catch’s picture

Yep that's all it should need.

chx’s picture

nope, it was entity_invoke('insert', $entity_type, $entity) the hook is module_invoke_all('insert', $entity, $entity_type);

klausi’s picture

API freeze isn't taken that serious these days ;-)

issue for entity: #836754: API change: entity_invoke() got removed

jhodgdon’s picture

I closed that as a duplicate.

webchick’s picture

Hm. I remember raising holy hell about this function back in the day, but someone (yched?) made some sort of argument as to why it was required. Don't remember it now. Maybe Barry knows? Or maybe we in fact don't need it anymore after subsequent changes to the entity system?

jhodgdon’s picture

If it had some other behaviors like node_invoke() does [figuring out which module is responsible for the node], then maybe.

But as it was a simple one-line function, why not just have the calling functions do the one line? That removes the function call overhead, and I think the resulting code was cleaner (or at least as clean).

kaynen’s picture

I got this while attempting to install the latest dev version. Was entity_invoke() removed from dev? It appears there's still a call to it in Taxonomy.

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: http://kaynen.com/drupal/install.php?q=install.php&profile=standard&loca... StatusText: OK ResponseText: Fatal error: Call to undefined function entity_invoke() in /home/kaynen/public_html/drupal/modules/taxonomy/taxonomy.module on line 377

UPDATE:

Ignore this- I had an issue with old files not being deleted.

bjaspan’s picture

@webchick: I think you raised hell about _field_invoke(), a utility function completely internal to field.attach.inc that takes a $op parameter. I (and I'm pretty sure yched) stand by it.

I don't even know what entity_invoke() is, so I can't comment on it.

Status: Fixed » Closed (fixed)
Issue tags: -API change

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