WP Query filter search. Result show all posts instead just custom post type

Ok, i found bug in theme, and that is searching just posts in all theme.

if (!is_admin()) {
    function wpb_search_filter($query) {
  if ($query->is_search) {
    $query->set('post_type', 'post');
  }
  return $query;
  }
  add_filter('pre_get_posts','wpb_search_filter');
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)