#33710 closed defect (bug) (fixed)
Displaying a comment whose comment_parent has been deleted results in PHP Notices
Reported by: | rachelbaker | Owned by: | rachelbaker |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | has-patch commit |
Focuses: | administration | Cc: |
Description
There are missing checks in the Comments (wp-admin/edit-comments.php) and Edit Comment (wp-admin/comment.php?action=editcomment&c={comment_ID}) screens for comments that have a comment_parent
value. If the comment parent was deleted , or for some reason doesn't exist, get_comment( $comment->comment_parent )
won't return an object. In both screens we do not check that we have a parent object before calling get_comment_link()
or get_comment_author()
, both of which also assume a comment object exists, which result in PHP Notice: Trying to get property of non-object messages.
Assuming your PHP error reporting level includes Notices, you log or display the errors, and you enjoy replicating bugs; here are the steps to reproduce:
- Create a test comment
- Reply to the test comment
- Delete the test comment created in step 1
- View the Comments screen
- Note the PHP Notices (example https://cloudup.com/cpH6cjQry-a)
- Locate your parentless comment (the reply created in step 2) in the list table and click the "Edit" link
- View the Edit Comment screen
- Note the PHP Notices (example: https://cloudup.com/ckUOLcdVCY5)
- Throw laptop out window
Attachments (4)
Change History (13)
#2
@
9 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 4.4
#4
@
9 years ago
esc_attr()
is only useful for HTML attributes, which is not the case here.
Comment author name already runs through sanitize_text_field()
and KSES filters, it should be safe.
This ticket was mentioned in Slack in #core by sergey. View the logs.
9 years ago
#6
@
9 years ago
- Keywords needs-refresh added
I churned the Comment List Table code, patch needs a reboot
#7
@
9 years ago
- Keywords commit added; needs-refresh removed
@wonderboymusic
attachment:33710.2.patch refreshes the patch. Added commit
keyword for your consideration.
Patch checks if the comment parent object exists and if it does escapes the comment parent author's name.