I’m trying to finish up the Revo version of News Publisher. The Evo version forwards the user to the newly created resource.
I can make that work in Revo, but only if I clear the cache before forwarding. AFAIK, in Evo it worked whether you cleared the cache or not (since clearcache is an option).
In Revo, even if I save the resource, then make the URL myself, sendRedirect() fails unless the cache is cleared first. It doesn’t seem like this should be necessary, and in a site where lots of users are creating resources in the front end (e.g., a simple blog), it would be a serious performance hit if the cache is cleared every time someone posts. I would have thought that if the resource isn’t found in the cache during the sendRedirect() process, it would be retrieved from the DB.
Is there some trick I haven’t hit on that will make this work without clearing the cache?
The resource create processor clears the cache with this code :-
if (!empty($scriptProperties['syncsite']) || !empty($scriptProperties['clearCache'])) {
/* empty cache */
$cacheManager= $modx->getCacheManager();
$cacheManager->clearCache(array (
"{$resource->context_key}/",
),
array(
'objects' => array('modResource', 'modContext', 'modTemplateVarResource'),
'publishing' => true
)
);
}
on resource creation, so it seems it may be necessary.
Use MODx, or the cat gets it!
Thanks. I’m already doing that, but it looks like the problem might be the aliasmap and I wonder if I could just update that myself or if it could be updated in the resource’s save() method.
Updating the aliasMap doesn’t seem to help, so I guess clearing the cache is necessary, though I don’t see why from a design standpoint since the resource is theoretically in the DB at this point.
When Frontpage creates a page it doesn’t auto forward to the new page, you have to go there yourself but this did work, at least with id’s, I didn’t try with aliases though. I also noticed that if the page is created in a container that Wayfinder is producing links from the link to the new page didn’t show up until I cleared the site cache, refreshed the page and the link appeared. I didn’t have time at the time to look at this further, from your experiences looks as though I need to clear the cache from my creation code also.
Use MODx, or the cat gets it!
It looks to me like there’s no way to generate a FURL of any kind before the aliasMap is updated.
sendRedirect() to the newly create page works for me if the cache is cleared. Are you saying that it’s not reliable? It’s how NewsPublisher has worked for a long time.
Quote from: OpenGeek at Nov 27, 2010, 05:34 PM
Quote from: BobRay at Nov 27, 2010, 01:06 PM
sendRedirect() to the newly create page works for me if the cache is cleared. Are you saying that it’s not reliable? It’s how NewsPublisher has worked for a long time.
Only if you manually reload that data into memory; remember, the first thing that happens in a request is that the cached settings are loaded. This does not happen again in the request cycle.
Sorry, I’m not following. Doesn’t sendRedirect() initiate a new request cycle that would reload the cache (including the new doc) if it had been cleared?