WordPress.org

Make WordPress Core

Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#25151 closed defect (bug) (fixed)

comment_form() function treats $args as array before passing $args through wp_parse_args()

Reported by: tomdxw Owned by: SergeyBiryukov
Milestone: 3.6.1 Priority: normal
Severity: normal Version: 3.6
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

To reproduce simply call comment_form('fields=author'); with WP_DEBUG switched on. It will result in the following errors:

PHP Warning: Illegal string offset 'format' in /path/to/wordpress/wp-includes/comment-template.php on line 1610
PHP Warning: Illegal string offset 'format' in /path/to/wordpress/wp-includes/comment-template.php on line 1614

This appears to be a bug introduced in 3.6.

Attachments (1)

25151.patch (515 bytes) - added by SergeyBiryukov 11 months ago.

Download all attachments as: .zip

Change History (9)

comment:1 nacin11 months ago

  • Milestone changed from Awaiting Review to 3.6.1

comment:2 SergeyBiryukov11 months ago

Introduced in [24417].

SergeyBiryukov11 months ago

comment:3 SergeyBiryukov11 months ago

  • Keywords has-patch added

The simplest solution is probably to call wp_parse_args() twice.

comment:4 follow-up: nacin11 months ago

If current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml' is added to the $defaults array for 'format', would that work? Then these lines could be removed.

comment:5 in reply to: ↑ 4 SergeyBiryukov11 months ago

Replying to nacin:

If current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml' is added to the $defaults array for 'format', would that work? Then these lines could be removed.

No, we use it to set $fields, which is a part of $defaults array itself: tags/3.6/wp-includes/comment-template.php#L1614.

comment:6 nacin11 months ago

I think 25151.patch is probably good, then.

comment:7 SergeyBiryukov11 months ago

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

In 25151:

Make sure $args is an array before treating it as such. fixes #25151 for trunk.

comment:8 SergeyBiryukov11 months ago

In 25152:

Make sure $args is an array before treating it as such. fixes #25151 for 3.6.

Note: See TracTickets for help on using tickets.