Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.

 

Restrictions are not indexed for the child pages when indexed them in the ContentSecuritySaved event

Vote:
 

I need to index the child pages when an editor changes the restrictions in a page in CMS.

So, I have handled the ContentSecuritySaved event like below to index all the child pages.

 [InitializableModule]
    public class SecurityEventInitializationModule : IInitializableModule
    {
        public void Initialize(InitializationEngine context)                
        {            
            var secRepos = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentSecurityRepository>();            
            secRepos.ContentSecuritySaved += secRepos_ContentSecuritySaved;
            
        }        

        public void Preload(string[] parameters) { }

        public void Uninitialize(InitializationEngine context)
        {
            var secRepos = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentSecurityRepository>();
            secRepos.ContentSecuritySaved -= secRepos_ContentSecuritySaved;
        }

        void secRepos_ContentSecuritySaved(object sender, ContentSecurityEventArg e)
        {
           List<IContent> childPages = GetAllChildren(e.ContentLink);

           // Index all child pages
           IContentIndexer indexer = ContentIndexer.Instance;
           indexer.Index(childPages);
        }
    }

It indexes the child pages, but it does not correctly update the restrictions in the index (EPiServer.Find.Cms.ContentExtensions.RolesWithReadAccess property).
In the Find index, The child pages always have the previous restrictions we have defined.

How to have the current restrictions in the Find index ?

More Info on my setup:
All the child pages inherit the settings from parents.

#217440
Edited, Feb 24, 2020 10:25
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.