Sitecore GetItem and GetChildren not returning Restricted Items
The problem
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Item parentNode= master.GetItem("ItemNAme");
var childItems=parentNode.GetChildren();
Only returned children that did not have Restricted Publishing, the same happend when using GetDescendends and FastQuery. Finally a trial with GetItem on a restricted item also gave a null...Details
Very useless if your job was to loop through a hierarchy and synchronize items and their publishing restrictions. We had seen the bug earlier but it had gone away with no explanation...I tried several searchs
sitecore+query+include+publishing+restriction
sitecore+publishing+restrictions+removes+from+GetDescendents
sitecore+publishing+restrictions+removes+from+GetDescendents
Sitecore+navigating+the+item+tree+publishing+restriction
sitecore+children+vs.+getchildren
Came close on this one:
http://stackoverflow.com/questions/9428346/sitecore-get-child-items-of-parent-item-when-the-items-are-in-publish-restricte/
But it was first on the 5th coworker I showed the issue that he got the right google search going.
The Solution
When IsPreview is true (cookie based) and Filtering on the site config is allowed you will not get Items with publishing restrictions. This functionality is from the implementation of the PageEditor Preview where you need to browse the master database as if published items where not visible.
Sitecore Publishable flag makes it impossible to GetItem() from Master database
http://stackoverflow.com/questions/16838825/sitecore-publishable-flag-makes-it-impossible-to-getitem-from-master-database
No comments: