I want to patch the configuration for sharedSessionState
to use MSSQL instead of memory. The default configuration from Sitecore.Analytics.Tracking.config
renders as such:
Sitecore.Analytics.Tracking.config
<sharedSessionState defaultProvider="InProc">
<providers>
<clear/>
<add name="InProc" type="System.Web.SessionState.InProcSessionStateStore"/>
</providers>
<manager type="Sitecore.Analytics.Tracking.SharedSessionState.SharedSessionStateManager, Sitecore.Analytics">
<param desc="configuration" ref="tracking/sharedSessionState/config"/>
</manager>
<config type="Sitecore.Analytics.Tracking.SharedSessionState.SharedSessionStateConfig, Sitecore.Analytics">
<param desc="maxLockAge">5000</param>
<param desc="timeoutBetweenLockAttempts">10</param>
</config>
</sharedSessionState>
The goal is to change the defaultProvider
attribute and to replace the InProc
provider. I attempt to do this with the following patch file:
z.Patch.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<tracking>
<sharedSessionState defaultProvider="InProc">
<patch:attribute name="defaultProvider" value="mssql" />
<providers patch:instead="providers">
<clear />
<add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider,Sitecore.SessionProvider.Sql" connectionStringName="sharedsession" pollingInterval="2" compression="true" sessionType="shared"/>
</providers>
</sharedSessionState>
</tracking>
</sitecore>
</configuration>
This patch results in the sharedSessionState
correctly changing its defaultProvider
, but the providers
element is completely missing. At first I thought the patching engine couldn't find the right place to add the element, given that I changed its parent in the same configuration, but fiddling around I discovered that the following patch does include the providers
element correctly:
z.ModifiedPatch.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<tracking>
<sharedSessionState defaultProvider="InProc">
<patch:attribute name="defaultProvider" value="mssql" />
<providers customAttribute="whatever" patch:instead="providers">
<clear />
<add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider,Sitecore.SessionProvider.Sql" connectionStringName="sharedsession" pollingInterval="2" compression="true" sessionType="shared"/>
</providers>
</sharedSessionState>
</tracking>
</sitecore>
</configuration>
The only change introduced in this modified patch is the addition of customAttribute="whatever"
to the providers
element.
Why is it seemingly not possible replace an element with an attribute-less element? Is there a better work-around in general than to add a bogus attribute?