Fix php errors with filters

This fixes the php errors that occur when clicking on View State, Match Type, and Highlight Changed.

The change includes:
- When a filter is retrieved for a user, if the user doesn't have a filter or something is wrong with it, return default fitler.
- Move access to $g_filter into the filter_api and introduce filter_init() API.  Default $g_filter in filter_api as well.
- View State initialization should use correct type to avoid type mismatch in check_selected().

Fixes #17654