Handle undefined theme the right way

Sorry for the confusion.
This is the right way to do #10236.
This has never caused any issues, has it?
cc @MiguelCastillo