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.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 834924-remove-entity-invoke.patch | 7.03 KB | jhodgdon |
Comments
Comment #1
chx CreditAttribution: chx commentedTotally +1
Comment #2
jhodgdonI'm making a patch.
Comment #3
jhodgdonThe code is so much cleaner without this...
Comment #4
chx CreditAttribution: chx commentedWell 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.
Comment #5
mikey_p CreditAttribution: mikey_p commentedchx 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.
Comment #6
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #7
catchThis 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.
Comment #8
rfayI 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?
Comment #9
catchYep that's all it should need.
Comment #10
chx CreditAttribution: chx commentednope, it was entity_invoke('insert', $entity_type, $entity) the hook is module_invoke_all('insert', $entity, $entity_type);
Comment #11
klausiAPI freeze isn't taken that serious these days ;-)
issue for entity: #836754: API change: entity_invoke() got removed
Comment #12
jhodgdonI closed that as a duplicate.Comment #13
webchickHm. 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?
Comment #14
jhodgdonIf 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).
Comment #15
kaynen CreditAttribution: kaynen commentedI 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.
Comment #16
bjaspan CreditAttribution: bjaspan commented@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.