Join GitHub today
v8 cannot access published content during startup #4572
This might not be super common but i'm sure it's common enough to need.
Articulate currently accesses the content cache on startup because it needs to define MVC routes based on what routes umbraco has already created for Articulate root nodes.
Currently you can't really access the content cache from within the Initialize method of your composer.
Another oddity is that the IPublishedSnapshotAccessor has a get/set for the
To work around all of this, what I need to do in Articulate is:
See PR #4577 - and we really should merge this, or anything similar, before releasing.
What I have done:
Now, components run before any request, and so don't have a "current" context. They need to explicitely use a context. The following code works on my machine:
Note that withing the
OTOH, if there is no current context, it creates a context, makes it the current one, and returns a reference to that context - and the reference is configured so that when it's disposed, the context is disposed too, and it's de-registered (ie no more current context).
This way, if you write code that may run within a request, and also may run outside a request, wrapping things in such a