Fix bug DNN-4843: only use new PortalSettings when httpcontext is null and portal id is not -1.