diff --git a/includes/classes/Feature/Search/Weighting.php b/includes/classes/Feature/Search/Weighting.php index 0653bcb11e..3ac33b60ac 100644 --- a/includes/classes/Feature/Search/Weighting.php +++ b/includes/classes/Feature/Search/Weighting.php @@ -359,6 +359,9 @@ public function recursively_inject_weights_to_fields( &$fieldset, $weights ) { } if ( is_array( $fieldset ) && isset( $fieldset['fields'] ) ) { + if ( ! is_array( $fieldset['fields'] ) ) { + $fieldset['fields'] = []; + } // Add any fields to the search that aren't already in there (weighting handled in next step) foreach ( $weights as $field => $settings ) { if ( ! in_array( $field, $fieldset['fields'], true ) ) { @@ -386,7 +389,7 @@ public function recursively_inject_weights_to_fields( &$fieldset, $weights ) { // else: Leave anything that isn't explicitly disabled alone. Could have been added by search_fields, and if it is not present in the UI, we shouldn't touch it here // If fieldset has fuzziness enabled and fuzziness is disabled for this field, unset the field - if ( isset( $fieldset['fuzziness'] ) && $fieldset['fuzziness'] && isset( $weights[ $field ]['fuzziness'] ) && false === $weights[ $field ]['fuzziness'] ) { + if ( isset( $fieldset['fuzziness'] ) && $fieldset['fuzziness'] && isset( $weights[ $field ] ) && isset( $weights[ $field ]['fuzziness'] ) && false === $weights[ $field ]['fuzziness'] ) { unset( $fieldset['fields'][ $key ] ); } }