Workaround Mentioned by @MarkCassidy:
As mentioned by Mark in the comments on this post, you could work around this issue by writing a handler for the publish:complete
event that executes the database cleanup for the Web database. Note that this may or may not be the most desirable solution - I still recommend reaching out to Sitecore first, in case they have a more efficient patch.
What you would need is a patch-config, similar to the following:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events>
<event name="publish:complete">
<handler type="MyProject.EventHandlers.DatabaseCleanup, MyProject" method="OnPublishComplete" />
</event>
</events>
</sitecore>
</configuration>
And then a class similar to the following:
namespace MyProject.EventHandlers
{
public class DatabaseCleanup
{
public void OnPublishComplete(object sender, EventArgs args)
{
var sitecoreArgs = args as Sitecore.Events.SitecoreEventArgs;
if (sitecoreArgs == null)
{
return;
}
var publishingOptions = sitecoreArgs.Parameters[0] as IEnumerable<DistributedPublishOptions>;
if (publishingOptions == null)
{
return;
}
var targetDatabases = publishingOptions
.Select(option => option.TargetDatabaseName);
foreach(var databaseName in targetDatabases)
{
var database = Sitecore.Configuration.Database.GetDatabase(databaseName);
database?.CleanupDatabase();
}
}
}
}