WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 2 months ago

#8177 new defect (bug)

Comments disabled in post but not in media gallery

Reported by: canon2k5 Owned by:
Priority: normal Milestone: 3.6
Component: Gallery Version: 2.7
Severity: normal Keywords: has-patch
Cc: janbrasna

Description (last modified by lloydbudd)

The options to "allow comments on this post" and "allow trackbacks and pingbacks on this post" have been deselected. The post will then return the expected message "Both comments and pings are currently closed". (ie. http://localhost/wordpress/?p=42) However, when selecting an image from an embedded native Gallery of that post, the image redirects to an attachment_id (ie. http://localhost/wordpress/?attachment_id=38)and still has a comments field. There is no decipherable means to disable comments on attachments through the native gallery.

If this is the expected behavior, I would believe that if a post may disable comments, then all of its content should be disabled.

Related: #9839 Enable/Disable comments on a per item bases (some attachments don't have parents)

Attachments (4)

8177.diff (3.2 KB) - added by DD32 4 years ago.
8177.2.diff (6.4 KB) - added by obenland 7 months ago.
8177.3.diff (7.7 KB) - added by obenland 3 months ago.
8177.4.diff (7.7 KB) - added by obenland 3 months ago.

Download all attachments as: .zip

Change History (37)

comment:1 ryan5 years ago

What theme are you using? This is probably a theme bug.

comment:2 janbrasna5 years ago

  • Cc janbrasna added
  • Keywords image gallery attachment commenting discussion preference added

Confirming the bug in 2.7-beta3-9922 however not sure about possible solutions. Should commenting preferences be inherited from the attachment's parent post? Or set explicitly per attachment?

comment:3 janbrasna5 years ago

  • Keywords dev-feedback 2nd-opinion added
  • Milestone changed from 2.8 to 2.7

comment:4 westi5 years ago

  • Keywords reporter-feedback added; dev-feedback 2nd-opinion removed

Please let us know what theme you are using.

comment:5 DD325 years ago

I dont think its a theme bug, Well, If it is, Its because the bug exists in the default theme.

<?php if ('open' == $post->comment_status) : ?>

The theme only checks that the current post's(attachment) comment status is open, And closing the status on a parent doesnt follow through to children.

A potential solution would be to do a lookup on the parent and check its comment_status, and set the attachment to the same during the query.

comment:6 ryan5 years ago

  • Milestone changed from 2.7 to 2.8

We should add parent checking to pings_open() and comments_open() and encourage themes to use those. There is no time to do this for 2.7, however. Postponing to 2.8.

comment:7 janbrasna5 years ago

The problem probably starts at the point when the attachment's data is pulled from DB to $post since both comment_status and ping_status are set to open in DB.

The question is, wouldn't it be better to explicitly set the pings&comments for individual attachments directly?

comment:8 DD324 years ago

  • Keywords needs-patch added

DD324 years ago

comment:9 DD324 years ago

  • Keywords has-patch needs-testing added; image gallery attachment commenting discussion preference reporter-feedback needs-patch removed

attachment 8177.diff added.

  • Sets comment/ping status to the parent posts status for attachments
  • Supports themes which use if ('open' == $post->comment_status) instead of comments_open()
  • Note, The changes to _close_comments_for_old_posts are so the closed-comments-on-the-fly work for the front page commenting links.. Included in this patch simply for review sake, The functionality for this ticket works without it.

comment:10 DD324 years ago

  • Keywords tested dev-feedback added; needs-testing removed

Any traction?

comment:11 Denis-de-Bernardy4 years ago

i'm not a big fan of this patch. imo, the open/closed status for comments should have an additional value, inherit, which does just that.

comment:12 Denis-de-Bernardy4 years ago

  • Keywords commit added

then again, it's better than the current behavior...

comment:13 azaozz4 years ago

Currently comments on attachments respect the close_comments_for_old_posts setting. Perhaps all that's needed is to check whether comments are open on the parent post when outputting an attachment post.

comment:14 dd324 years ago

Perhaps all that's needed is to check whether comments are open on the parent post when outputting an attachment post.

Thats pretty much what the patch does.. Except, It does it when the attachment post object is loaded, so that it also affects front-page links instead of incorrectly showing "Comment now!" when comments are closed.

comment:15 hakre4 years ago

Hmm, isn't that a configuration issue? I mean, the attachment actually has comments according to the comment settings data. Shouldn't the date be set properly while updating the parent post? Or can attachment be shared between multiple posts and therefore there is need to handle that dynamically?

comment:16 dd324 years ago

. Shouldn't the date be set properly while updating the parent post?

the parent posts's setting can be dynamic, Ie. Close old comments doesnt change it in hte DB, it happens on the PHP-level to reduce database load.

comment:17 Denis-de-Bernardy4 years ago

  • Keywords early added
  • Milestone changed from 2.8 to 2.9

Punting per IRC discussion.

Things have been this way for months, it can stay that way for another few months. A minuscule plugin can fix it in the meanwhile.

comment:18 hakre4 years ago

I just checked. The default behavior is that (genreal option to allow comments is set to on), that when you create a post and add a gallery (wether or not the post has comments switched on in post settings) the attachments _ever_ have the option to comment on.

I would not only suggest to move this request into the plugin domain but into the theme domain. If this bevhavior is not intented, the theme must check for the attachements if the parent post allows comments or not.

The other route would be to extend the attachment editor having it's own comment setting input controls. Having or not that feature should clarify wether that is wanted or not.

See current patch for some code fragments on how to check for attachemnts parent open status.

Personally, I do not want to loose the ability to have comments on attachments but not on the parent post.

Resolve as "won't fix"?

comment:19 dd324 years ago

  • Keywords 2nd-opinion added; has-patch tested commit early removed

2.9 will get some media attention i believe.

I'd like to see an option added in 2.9 for the settings, as in, "Attachments inherit parents pingback/commenting settings" with per-image(& possible per-gallery) comment/pingback handling as well.

Leaving this open for discussion in 2.9 depending on where the UI goes.

comment:20 Denis-de-Bernardy4 years ago

  • Keywords needs-patch added; dev-feedback 2nd-opinion removed

let's leave it open then

comment:21 azaozz4 years ago

  • Milestone changed from 2.9 to 3.0

Most media changes will be in 3.0

comment:22 dd323 years ago

  • Milestone changed from 3.0 to Future Release

Punting again, due to limited traction on the media items.

comment:23 lloydbudd3 years ago

  • Description modified (diff)

comment:24 iandstewart2 years ago

With probable media enhancements in 3.3 is there any chance of this making someone's todo list?

obenland7 months ago

comment:25 obenland7 months ago

  • Keywords has-patch added; needs-patch removed

Refreshed @dd32's patch.
Since 3.5 is almost out the door, maybe this could be something for 3.6?

The issue is still current, the patch still works! :)

comment:27 SergeyBiryukov4 months ago

  • Milestone changed from Future Release to 3.6

comment:28 SergeyBiryukov3 months ago

If we're removing $query->is_singular() check, I guess the $query parameter (added in [18836]) should be removed as well, since it's not used anywhere else.

comment:29 obenland3 months ago

Nice catch. I updated the patch.

obenland3 months ago

comment:30 SergeyBiryukov3 months ago

"10, 2" in line 190 of default-filters.php should also be removed.

obenland3 months ago

comment:31 obenland3 months ago

Updated patch.

comment:32 ocean902 months ago

Related: #12991, #17478

Last edited 2 months ago by ocean90 (previous) (diff)

comment:33 obenland2 months ago

I talked with ocean90 in IRC about it and we agree that we should probably not add that functionality after all.

Since 3.5, attachments can not only be attached to more than one post, but they now also offer the ability to change their discussion settings individually, on a per attachment basis.

What do you think, Sergey?

Note: See TracTickets for help on using tickets.