Fix optimize command and view resolver for unknown extensions. Fixes #4688
Merge branch '4.2'