WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#48943 closed defect (bug) (fixed)

`comment_form()` expects optional "email" field to be passed.

Reported by: Mat Lipe Owned by: SergeyBiryukov
Milestone: 5.3.1 Priority: normal
Severity: normal Version: 5.3
Component: Comments Keywords: has-patch
Focuses: template Cc:

Description (last modified by SergeyBiryukov)

Ticket #47975 introduced a requirement to the comment_form template tag of a passed field['email'] argument.

When using comment_form without passing field['email'] to the $args parameter you get the following notice level error.

Undefined index: email
\wp-includes\comment-template.php:2440

I have confirmed the issue does not exist on WP 5.2.4.

I have included a patch which simply checks for the existence of the email array key before using it.

Attachments (2)

comment-template.php.diff (701 bytes) - added by Mat Lipe 7 months ago.
Patch the /wp-includes/comment-template.php file
48943.diff (717 bytes) - added by audrasjb 7 months ago.
Refreshed patch against trunk

Download all attachments as: .zip

Change History (9)

@Mat Lipe
7 months ago

Patch the /wp-includes/comment-template.php file

#1 @Mat Lipe
7 months ago

I should point out this only happens when the fields is provided as an argument without the "email" key. If you do not provided fields the defaults fill in the "email" key for you and this error does not occur.

#2 @SergeyBiryukov
7 months ago

  • Description modified (diff)

#3 @SergeyBiryukov
7 months ago

  • Milestone changed from Awaiting Review to 5.3.1

#4 @audrasjb
7 months ago

  • Keywords needs-refresh added

#5 @SergeyBiryukov
7 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 46885:

Comments: Avoid a PHP notice in comment_form() if the email field is not set.

Follow-up to [46090].

Props mat-lipe.
Fixes #48943.

#6 @SergeyBiryukov
7 months ago

In 46886:

Comments: Avoid a PHP notice in comment_form() if the email field is not set.

Follow-up to [46090].

Props mat-lipe.
Merges [46885] to the 5.3 branch.
Fixes #48943.

@audrasjb
7 months ago

Refreshed patch against trunk

#7 @audrasjb
7 months ago

  • Keywords needs-refresh removed

Ah nice, thanks Sergey, you beat me by committing it directly :D

@mat-lipe welcome to WordPress Trac and thank you for your patch!

Please note that the patch should be generated against trunk/wordpress-develop. Here is the GitHub mirror to clone wordpress-develop sources: https://github.com/WordPress/wordpress-develop :-)

Note: See TracTickets for help on using tickets.