Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search.php: Issues when clearing search in wp admin. #363

Open
StevenDufresne opened this issue Nov 13, 2023 · 1 comment · May be fixed by #496
Open

Search.php: Issues when clearing search in wp admin. #363

StevenDufresne opened this issue Nov 13, 2023 · 1 comment · May be fixed by #496

Comments

@StevenDufresne
Copy link
Contributor

When you clear a search on a custom post type, you get an error in Wp-admin.

I think this issue has always existed in the local environment as git blame takes me back to the import commit.

GIF

Screen Capture on 2023-11-13 at 15-08-23

Steps to reproduce

  1. Visit any of the custom post types locally
  2. Search for something
  3. Clear the input box and search ago.
  4. Notice you get the following error:
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /var/www/html/wp-content/themes/wporg-developer-2023/inc/search.php:237 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(324): DevHub_Search::redirect_empty_search(Array, Object(WP_Query)) #1 /var/www/html/wp-includes/plugin.php(256): WP_Hook->apply_filters(Array, Array) #2 /var/www/html/wp-includes/class-wp-query.php(3530): apply_filters_ref_array('the_posts', Array) #3 /var/www/html/wp-includes/class-wp-query.php(3824): WP_Query->get_posts() #4 /var/www/html/wp-includes/class-wp.php(696): WP_Query->query(Array) #5 /var/www/html/wp-includes/class-wp.php(816): WP->query_posts() #6 /var/www/html/wp-includes/functions.php(1336): WP->main(Array) #7 /var/www/html/wp-admin/includes/post.php(1304): wp(Array) #8 /var/www/html/wp-admin/includes/class-wp-posts-list-table.php(165): wp_edit_posts_query() #9 /var/www/html/wp-admin/edit.php(235): WP_Posts_List_Table->prepare_items() #10 {main} thrown in /var/www/html/wp-content/themes/wporg-developer-2023/inc/search.php on line 237
@pkevan
Copy link

pkevan commented Feb 5, 2024

Also produces as warning on production. We just need to skip in admin context this code or change the context to be more specific as it's currently running on the_posts.

@pkevan pkevan linked a pull request Feb 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants