WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 8 weeks ago

#48449 new defect (bug)

Parameters differ between instances of widget_comments_args filter

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0
Component: Comments Keywords: needs-testing has-patch
Focuses: Cc:
PR Number:

Description

The widget_comments_args filter is applied in two different places, but with different parameters:

  1. https://core.trac.wordpress.org/browser/tags/5.2.4/src/wp-includes/widgets/class-wp-widget-recent-comments.php?marks=99-107#L86
  2. https://core.trac.wordpress.org/browser/tags/5.2.4/src/wp-includes/blocks/latest-comments.php?marks=46-53#L35

Note that the second instance doesn't have access to an $instance.

Attachments (1)

48449.diff (787 bytes) - added by fahdi 8 weeks ago.
Wp Recent Comments widget file updated to get rid of instance which is not needed anymore. This is so that the arguements are consistent

Download all attachments as: .zip

Change History (5)

@fahdi
8 weeks ago

Wp Recent Comments widget file updated to get rid of instance which is not needed anymore. This is so that the arguements are consistent

#2 @fahdi
8 weeks ago

  • Keywords needs-testing added; needs-patch removed

I have attached the patch for the solution that I believe is good. The solution is to either add aninstance argument for the filter in the file

https://core.trac.wordpress.org/browser/tags/5.2.4/src/wp-includes/blocks/latest-comments.php?marks=46-53#L35

which doesn't make any sense as we don't have any way to pass an instance. Looking at

https://core.trac.wordpress.org/browser/tags/5.2.4/src/wp-includes/widgets/class-wp-widget-recent-comments.php?marks=99-107#L86 , just removing instance from the parameters should solve and now we have the same consistent number of parameters in both calls.

#3 @SergeyBiryukov
8 weeks ago

Thanks for the patch!

I don't think we can just remove the $instance parameter from the filter, as that could cause backward compatibility issues and would be inconsistent with other widget filters, as seen in [41685].

I guess we can pass an empty array as $instance in render_block_core_latest_comments(), but that should be done upstream in the Gutenberg repository, per comment:5:ticket:48447.

#4 @fahdi
8 weeks ago

  • Keywords has-patch added

@SergeyBiryukov Makes sense. Going to send another patch.

Note: See TracTickets for help on using tickets.