#33710 closed defect (bug) (fixed)
Displaying a comment whose comment_parent has been deleted results in PHP Notices
| Reported by: | rachelbaker | Owned by: | rachelbaker |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.4 |
| Component: | Comments | Version: | |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: | administration |
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_parentvalue. 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)
#4
@
11 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.
11 years ago
#6
@
11 years ago
- Keywords needs-refresh added
I churned the Comment List Table code, patch needs a reboot
#7
@
11 years ago
- Keywords commit added; needs-refresh removed
@wonderboymusic
attachment:33710.2.patch refreshes the patch. Added commit keyword for your consideration.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Patch checks if the comment parent object exists and if it does escapes the comment parent author's name.