Fix optimize command and view resolver for unknown extensions. Fixes #4688