Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#56503 closed defect (bug) (invalid)

PHP error on get_search_form()

Reported by: seansmyth's profile seansmyth Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch reporter-feedback close
Focuses: Cc:

Description (last modified by sabernhardt)

When using a search form like below,

echo get_search_form();

or

get_search_form();

a php error occurs.

Warning: Undefined array key "echo" in .../wp-includes/general-template.php on line 363

Change History (5)

This ticket was mentioned in PR #3175 on WordPress/wordpress-develop by seansmyth.


3 years ago
#1

  • Keywords has-patch added

As it was producing a php error

Warning: Undefined array key "echo" in /general-template.php on line 363

Trac ticket: [](https://core.trac.wordpress.org/ticket/56503#ticket)

#2 @sabernhardt
3 years ago

  • Description modified (diff)
  • Summary changed from PHP error on get_searh_form() to PHP error on get_search_form()

#3 @SergeyBiryukov
3 years ago

  • Keywords reporter-feedback added

Hi there, welcome to WordPress Trac! Thanks for the ticket and the patch!

At first I thought that while echo is one of the default arguments for get_search_form(), some plugin or theme could unintentionally remove it via the search_form_args filter, but it looks like the function already protects against that, see [49355] / #51645:

// Ensure that the filtered arguments contain all required default values.
$args = array_merge( $defaults, $args );

Looking at the error:

Warning: Undefined array key "echo" in .../wp-includes/general-template.php on line 363

it is worth noting that in WordPress 6.0.2, the if ( $args['echo'] ) conditional in question is line 357, not 363.

So I think the following would be helpful to move the ticket forward:

  • Could you share the steps to reproduce the issue on a clean install?
  • What is the version of WordPress you're using?
Last edited 3 years ago by SergeyBiryukov (previous) (diff)

#4 @desrosj
3 years ago

  • Keywords close added
  • Version trunk deleted

Adding a suggestion to close due to a lack of reporter feedback. Will circle back in a bit more time to close unless more details are shared.

#5 @JeffPaul
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing due to no response

Note: See TracTickets for help on using tickets.