As the title says...

CommentFileSizeAuthor
#1 2148709.patch1.5 KBamateescu

Comments

amateescu’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

Something like this.

Status: Needs review » Needs work

The last submitted patch, 1: 2148709.patch, failed testing.

yched’s picture

+1

andypost’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +Quick fix, +API clean-up

makes a lot of sense!
PS: better title would be - CommentManager::getFields() should return only content entities

yched’s picture

@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()...

amateescu’s picture

Why do multiple checks in various places when we can do just one? :)

yched’s picture

Yeah, 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...

amateescu’s picture

Then what we really need is a helper for this ugly piece of code, something like EntityManager->isContentEntityType().

webchick’s picture

Status: Reviewed & tested by the community » Fixed

I 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!

Status: Fixed » Closed (fixed)

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