There is some cache issue on modx, after an upgrade from modx 2.0.x
Clearing cache does not seems to fix the issue.
One way to fix it is to edit every resources which ever are effected...
Updates:
Another way is to do a script to run recursively on all resources, edit it by changing the alias, and save,
and then changing the alias back to the actual alias, and save it again.
Example:
function doFixResource($id, $iLevel=1) {
$oRes = $modx->getObject("modResource", $id);
$aContext = array($oRes->get("context_key"));
$iParentId = $oRes->get("parent");
if (!empty($iParentId)) {
doFixResource($iParentId, $iLevel+1);
}
echo "Fixing: " . $oRes->get("id") . "(lvl:" . $iLevel . ")," . $oRes->get("alias") . "::" . $oRes->get("pagetitle") . "(" . $oRes->get("context_key") . ")
\n";
$sAlias = $oRes->get("alias");
$oRes->set("alias", $sAlias . "-". rand(10000,9999));
$oRes->save(false);
//doFlushContext($aContext);
$oRes->set("alias", $sAlias);
$oRes->save(false);
doFlushContext($aContext);
}
then run flush script:
function doFlushContext($aContext) {
global $modx;
$modx->cacheManager->refresh(array(
'db' => array(),
'auto_publish' => array('contexts' => $aContext),
'context_settings' => array('contexts' => $aContext),
'resource' => array('contexts' => $aContext),
));
}
And finally, run clear cache from manager screen.
Tips: If you want performance, cached up all the id which you have run doFixResource by using static variable, and skip it, it may save you up to more than 80% of the time :)
No comments:
Post a Comment