Closed yiangos closed 4 years ago
Hi yiangos,
Thank you for reporting this. At this time however Habitat is not receiving any further updates as we are in process of replacing it with a new set of Helix Examples. In addition, Habitat is intended only as an example of solution architecture and thus may not contain production-ready code. If you are copying from Habitat into your own solution, your mileage may vary and you should modify to your needs.
Hello.
When deploying Habitat on a CM/CD environment, the Foundation.Multisite gives an arror that it can't find the core database. As I understand, the default CD installation removes the Core database definition. The offending piece of code is in the Sitecore.Foundation.Multisite.Providers.SiteDefinitionsProvider, method GetSiteRootItem. This method iterates over all site definitions existing in sitecore configuration and retrieves the root item for each. The issue here is that some of the site definitions have "core" as their database, and it seems that the call
var item = database?.GetItem(site.RootPath);
is not enough to prevent the unhandled error from happening.
I suggest a more defensive approach, i.e. a try/catch on the call
Database.GetDatabase(site.Database);
and in the catch simply set the database variable to null.
Then the call
var item = database?.GetItem(site.RootPath);
will not fail, and return null as it should.
I can prepare a pull request if the approach seems valid.