Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
comment.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Dec 2013 at 10:21 UTC
Updated:
29 Jul 2014 at 23:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
amateescu commentedSomething like this.
Comment #3
yched commented+1
Comment #4
andypostmakes a lot of sense!
PS: better title would be - CommentManager::getFields() should return only content entities
Comment #5
yched commented@andypost:
looks like a couple of the places that call Commentmanager::getFields($entity_type) could do that check themselves ? E.g comment_entity_insert(), comment_entity_load()...
Comment #6
amateescu commentedWhy do multiple checks in various places when we can do just one? :)
Comment #7
yched commentedYeah, no biggie - just that's gonna be a common D8 antipattern to do generic stuff in hook_entity_OP() and have it inadvertently run on all entity types while in fact the intended behavior only makes sense on ContentEntities...
In the end the result is going to be the same here, that just depends on what we want the "visible killswitch" to be in those comment_entity_OP() implementations...
Comment #8
amateescu commentedThen what we really need is a helper for this ugly piece of code, something like EntityManager->isContentEntityType().
Comment #9
webchickI was confused why we're doing this sort of hand-holding, and there was nothing in the issue summary about it.
This came about because a notice was accidentally introduced in #1503314: Remove the concept of active / inactive (field types, storage) from Field API due to passing a config entity into this function. Since config entities can't have fields attached, it makes sense to eliminate them from the results. We can't just use something standard like type hinting here because all we have to work with is a string.
I think that this is fine, although we typically don't add this sort of hand-holding into core, expecting people to read the docs and call functions properly. That said, targeted hand-holding can also save people a lot of grief. I don't know this area well enough to know if this is appropriate hand-holding or not, but it doesn't seem like it's in the critical path, so it's probably fine.
Committed and pushed to 8.x, plus a small docs update/fix for the entity_type parameter to reflect this change. Thanks!