Summary:
Add/Edit Content doesn't clear cache
Detailed Description:
Annoying Bug: When we add a page to cmsms, it doesn't show up in the admin's
content list, and the page doesn't work until the cache is cleared, which we
were using the move page up/down to get new pages to work.
I tracked it down, here's the fix.
### File #1: in /admin/addcontent.php find block:
$contentobj->Save();
global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentops->SetAllHierarchyPositions();
if ($submit)
{
audit($contentobj->Id(), $contentobj->Name(), 'Added Content');
redirect('listcontent.php'.$urlext.'&message=contentadded');
}
after $contentops->SetAllHierarchyPositions(); add:
$contentops->ClearCache();
completed block should look like:
$contentobj->Save();
global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentops->SetAllHierarchyPositions();
$contentops->ClearCache();
if ($submit)
{
audit($contentobj->Id(), $contentobj->Name(), 'Added Content');
redirect('listcontent.php'.$urlext.'&message=contentadded');
}
#### File #2: in /admin/addcontent.php find block:
$contentobj->SetLastModifiedBy(get_userid());
$contentobj->Save();
$contentops =& $gCms->GetContentOperations();
$contentops->SetAllHierarchyPositions();
audit($contentobj->Id(), $contentobj->Name(), 'Edited Content');
after $contentops->SetAllHierarchyPositions(); add:
$contentops->ClearCache();
completed block should look like:
$contentobj->SetLastModifiedBy(get_userid());
$contentobj->Save();
$contentops =& $gCms->GetContentOperations();
$contentops->SetAllHierarchyPositions();
$contentops->ClearCache();
audit($contentobj->Id(), $contentobj->Name(), 'Edited Content');
I'm guessing that there could be other places to fix this. It's probably all
instances of $contentops->SetAllHierarchyPositions(); needs to clear the cache
after.