WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

#51645 closed defect (bug) (fixed)

Undefined index: echo in core files

Reported by: kellybleck Owned by: SergeyBiryukov
Milestone: 5.5.2 Priority: normal
Severity: trivial Version: 5.2
Component: General Keywords: has-patch fixed-major
Focuses: template Cc:

Description

Updated to WordPress 5.5.1, and have my WP_DEBUG set to output to an error file. There is one that crops up all the time -

[22-Sep-2020 03:39:44 UTC] PHP Notice: Undefined index: echo in /var/www/httpdocs/wp-includes/general-template.php on line 350

Attachments (1)

51645.diff (404 bytes) - added by whyisjake 3 months ago.

Download all attachments as: .zip

Change History (10)

#1 @davidbaumwald
3 months ago

  • Focuses template added
  • Version changed from 5.5.1 to 5.5

Welcome to Trac, @kellybleck! This does indeed look like something that should be investigated.

In 5.2, the $args parameter was added and made filterable with the search_form_args filter. It looks like the filtered $args could unset the echo property and throw this notice when if ( $args['echo'] ) { is run.

My guess is that a simple isset sanity check would work here.

Last edited 3 months ago by davidbaumwald (previous) (diff)

#2 @davidbaumwald
3 months ago

  • Version changed from 5.5 to 5.2

Actually, this goes back to 5.2.

@whyisjake
3 months ago

#3 @whyisjake
3 months ago

  • Keywords has-patch dev-feedback added
  • Milestone changed from Awaiting Review to 5.5.2

#4 @SergeyBiryukov
3 months ago

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

#5 @SergeyBiryukov
3 months ago

I think a better fix here would be to ensure that all the default values are always set:

$args = wp_parse_args( $args, apply_filters( 'search_form_args', $defaults ) );

That way we don't have to check whether each individual argument exists.

The same approach is used in comment_form(), wp_login_form(), and register_sidebar().

#6 @SergeyBiryukov
3 months ago

On second thought, that does not fix the issue and changes the behavior of the filter to no longer receive custom values. Taking another look.

#7 @SergeyBiryukov
3 months ago

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

In 49355:

General: Ensure that filtered arguments in get_search_form() contain all required default values.

Props kellybleck, davidbaumwald, whyisjake, SergeyBiryukov.
Fixes #51645.

#8 @SergeyBiryukov
3 months ago

  • Keywords fixed-major added; dev-feedback removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.5 branch.

#9 @SergeyBiryukov
3 months ago

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

In 49356:

General: Ensure that filtered arguments in get_search_form() contain all required default values.

Props kellybleck, davidbaumwald, whyisjake, SergeyBiryukov.
Merges [49355] to the 5.5 branch.
Fixes #51645.

Note: See TracTickets for help on using tickets.