WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 4 months ago

#26665 closed defect (bug) (duplicate)

Exception is thrown on line query.php on line 1758 Warning: strpos() expects parameter 1 to be string

Reported by: syntaxart Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8
Component: Query Keywords:
Focuses: Cc:

Description

This exception is thrown when submitting a url such as http://testing.dev/vacancy/?country[]=australia&country[]=new-zealand

What is trying to be acheived?

I am trying to submit multiple terms per taxonomy using a checkbox list of values with the name set to name="country[]". The tax_query successfully works but an exception is printed to the window.

I have created a fix on my local machine which is to wrap the nested statement with

if (!is_array($term)) {
                    if (strpos($term, '+') !== false) {
                        $terms = preg_split('/[+]+/', $term);
                        foreach ($terms as $term) {
                            $tax_query[] = array_merge($tax_query_defaults, array(
                                'terms' => array($term)
                            ));
                        }
                    } else {
                        $tax_query[] = array_merge($tax_query_defaults, array(
                            'terms' => preg_split('/[,]+/', $term)
                        ));
                    }
                }

I also used the plugin Taxonomy Picker to test multiple selected terms, and the same exception is thrown.

Thank you very much for looking into this bug.

Regards

Ryan

Change History (1)

comment:1 SergeyBiryukov4 months ago

  • Component changed from General to Query
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of and #26308 and #17737.

Note: See TracTickets for help on using tickets.