Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#51263 closed defect (bug) (fixed)

PHP warning when editing comments in the administration comment edit screen

Reported by: regankhadgi's profile regan.khadgi Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5.2 Priority: normal
Severity: normal Version: 5.5
Component: Comments Keywords: has-screenshots commit fixed-major
Focuses: administration Cc:


When I tried to edit any comment in the administration comment edit screen, I get two php warnings like below in my debug.log file

[07-Sep-2020 18:03:22 UTC] PHP Notice: Undefined index: c in D:\xampp\htdocs\free-plugins\wp-admin\comment.php on line 39
[07-Sep-2020 18:03:22 UTC] PHP Notice: Trying to get property 'comment_post_ID' of non-object in D:\xampp\htdocs\free-plugins\wp-admin\comment.php on line 43

I haven't enabled any plugins and my site is running default Twenty Twenty theme. I had tried with multiple WP installation including a fresh installation and error showed up on all installations. I have also included the links to the screenshot which shall make the issue more clear.

Change History (11)

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Comments
  • Keywords reporter-feedback added

Hi there, welcome to WordPress Trac! Thanks for the report.

Just noting that I could not reproduce the issue on a clean install.

What does the URL look like when you're editing a comment? It should look like this:


where 123 is the ID of the comment being edited.

#2 @regan.khadgi
4 years ago

Hi there,

Thank you for the reply. Yes the URl looks like


The error doesn't show up on the screen itself but shows up on editing when debug mode is set to true in wp-config.php file. Last day I checked in my localhost but today I checked in site hosted in hostgators and the error showed up in different installations in live servers too. So that's a bit strange that error is not being replicated.

Version 0, edited 4 years ago by regan.khadgi (next)

#3 @regan.khadgi
4 years ago

Hello there,

I just debugged a bit more and it seems there is some issue with $_GET and $_POST. When I inspected in the comment edit form there is a input type hidden field with name as c which shall be addressed as


on the receiving end but when I checked in the comment.php file in exact line number then it is being addressed as


without checking isset or empty condition.

Please check these screenshot.

So probable solution might be using $_REQUEST instead of $_GET or $_POST as since same screen is being used to submit and display the comment edit form.

#4 @SergeyBiryukov
4 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Awaiting Review to 5.5.2

Indeed, I was able to reproduce the issue now. Thanks!

It happens when submitting the Edit Comment form, not when opening the page, as I originally thought.

Moving to 5.5.2 for investigation.

Last edited 4 years ago by SergeyBiryukov (previous) (diff)

#5 @SergeyBiryukov
4 years ago

  • Version changed from 5.5.1 to 5.5

Introduced in [48050] / #37826.

#6 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#7 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 48958:

Comments: Check if a valid comment ID was passed when editing a comment.

This avoids a PHP notice after submitting the Edit Comment form.

Props regan.khadgi.
Fixes #51263.

#8 @SergeyBiryukov
4 years ago

  • Keywords commit fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.5 branch.

#9 @regan.khadgi
4 years ago

I am glad that the issue has been reproduced and I could also see it has already been patched :) Waiting for the new version :)

#10 @SergeyBiryukov
4 years ago

Thanks again for the report :)

#11 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 48959:

Comments: Check if a valid comment ID was passed when editing a comment.

This avoids a PHP notice after submitting the Edit Comment form.

Follow-up to [48050].

Props regan.khadgi.
Merges [48958] to the 5.5 branch.
Fixes #51263.

Note: See TracTickets for help on using tickets.