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 :)
Merc Studio Tech Blog*
Sunday, January 29, 2012
Friday, January 27, 2012
modx 2.2 changes
$modx->getUser("contextname")
return anonymous user if no user is logged in to the context.
when getOne("Profile") is performed on anonymous user, will return null, so some error might be thrown.
modx->db->dbfunctions is now deprecated, so use the actual function from $modx itself.
for more information, refer here:
http://rtfm.modx.com/display/revolution20/Upgrading+MODx#UpgradingMODx-VersionSpecificChanges
http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1
Example of a big change:
return anonymous user if no user is logged in to the context.
when getOne("Profile") is performed on anonymous user, will return null, so some error might be thrown.
modx->db->dbfunctions is now deprecated, so use the actual function from $modx itself.
for more information, refer here:
http://rtfm.modx.com/display/revolution20/Upgrading+MODx#UpgradingMODx-VersionSpecificChanges
http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1
Example of a big change:
$modx->db->query is completely different from $modx->query
So you may use parseBinding to do your query.
Example:
$sSelectSQL = "select `parent`, `context_key` , id, `alias`, pagetitle, longtitle from modx_site_content where context_key=:contextand parent=:parent and `alias`=:alias and (published=0 or deleted=1)";
$aParam = array(":context" => "web",
":parent" => 1, ":alias" => "somealias");
$sResultSelectSQL = $modx->parseBindings($sSelectSQL, $aParam);
$stmt = $modx->query($sResultSelectSQL);
if (! $stmt) throw new Exception("SQL Failed: " . $sResultSQL);
//to fetch all
$aCount = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($aCount as $oRow) {
echo $oRow["id"];
}
//to fetch one
$oRow = $stmt->fetch($PDO::FETCH_ASSOC);
echo $oRow["id"];
And other class based method:
//to get an object row
$oRes = $modx->getObject("modResource", array("context_key" => "web", "parent" => 1, "alias" => "somealias"));
echo $oRes->get("id");
modx 2.2 modX::isFrontEnd() is undefined?
After doing an upgrade to modx2.2, editing any resources seems to throw this error.
Solution, go to package manager, upgrade tinymce plugin.
And we are all set to go! :)
Solution, go to package manager, upgrade tinymce plugin.
And we are all set to go! :)
modx 2.2 upgrade from 2.0 error 500
There were seems to some configuration changes from 2.0 to 2.2 on core/config/config.inc.php.
When i was upgrading, the test database seems to response with an error 500.
After inspecting core/cache/logs/error.log, it shows "no database selected"
So i went into editing core/config/config.inc.php and found the $dbase = "{dbase}"
Using setup with advanced configuration does not seems to do the trick.
The solution now is to edit core/config/config.inc.php and set $dbase = "`mydatabasename`"
and $database_dsn = 'mysql:host=localhost;dbname=mydatabasename;charset=utf8';
Take note on the different between the 2, one with `` delimiter, and one without.
Next, rerun setup for upgrade shall do the trick :)
When i was upgrading, the test database seems to response with an error 500.
After inspecting core/cache/logs/error.log, it shows "no database selected"
So i went into editing core/config/config.inc.php and found the $dbase = "{dbase}"
Using setup with advanced configuration does not seems to do the trick.
The solution now is to edit core/config/config.inc.php and set $dbase = "`mydatabasename`"
and $database_dsn = 'mysql:host=localhost;dbname=mydatabasename;charset=utf8';
Take note on the different between the 2, one with `` delimiter, and one without.
Next, rerun setup for upgrade shall do the trick :)
magento enable cookie issue on chrome and ie
I came across this problem while trying to test my localhost machine for adding a product to cart.
it turn out to be some sort of cookie session issue on magento.
changing session length nor disabling cookie checking does not seems to work.
its suppose to only happen on localhost testing machine, might work well on actual domain.
Setting up vhost and pointing using hosts file shall do the trick...
it turn out to be some sort of cookie session issue on magento.
changing session length nor disabling cookie checking does not seems to work.
its suppose to only happen on localhost testing machine, might work well on actual domain.
Setting up vhost and pointing using hosts file shall do the trick...
magento 1.5
Magento 1.5 doesnt allow one to addjs or addskinjs with a custom sorting order...
its because the head.phtml file is doesn't support it in getCssJsHtml() and getIncludes();
One way to solve it is to inject script directly into head.phtml, but put it into your own template folder...
copy from app/design/frontend/base/default/template/page/html/head.phtml to
app/design/frontend/[yourtemplate]/default/template/page/html/
Another thing to take note is getUrl and getSkinURL gotcha...
Example:
$this->getSkinUrl("js/java.js"); // return skin/frontend/[base_or_yourtemplate]/default/js/java.js
but
$this->getUrl("js/java.js"); // return http://yourbasepath.com/js/java.js/
Work around will be using $this->getUrl(""). "js/java.js"
its because the head.phtml file is doesn't support it in getCssJsHtml() and getIncludes();
One way to solve it is to inject script directly into head.phtml, but put it into your own template folder...
copy from app/design/frontend/base/default/template/page/html/head.phtml to
app/design/frontend/[yourtemplate]/default/template/page/html/
Another thing to take note is getUrl and getSkinURL gotcha...
Example:
$this->getSkinUrl("js/java.js"); // return skin/frontend/[base_or_yourtemplate]/default/js/java.js
but
$this->getUrl("js/java.js"); // return http://yourbasepath.com/js/java.js/
Work around will be using $this->getUrl(""). "js/java.js"
Tuesday, January 17, 2012
netonboard.com sucks?
Updates 2012 jan 18:
Finally, got their attention from facebook fanpage. Talked to their support, and got my email replied.
They should check their offline chat message if its provided on their website...
-----------------------------------------------------------------
Well, i tried to be professional in judging them.
If it wasn't because the client bought the hosting with them, i might not have to face their shit.
First, they change their hosting without our notice.
Previously things which works, now doesn't work, and they claim they never change anything,
In php point of programmer view, they disable error log.
Fine, as programmer, i will use ini_set to enable it to see what went wrong.
so my surprise, it came out error 500 instead.
so defnitely it has been disabled ini_set function... wth..
Next, if you php code doesnt close with ?>, it will also come out error 500, isn't this a norm in php to have unclosed tag? its to avoid unwanted endline charactor in the end to avoid being output out.
3rd, fine, lets fill in the support form for help..
After filling in the contact form, its been 1+ weeks and no response.
Okay, lets try call their support fella, went to voice mail...
Okay, lets try again, their "live chat",
waiting for operator, waiting for operator, waiting for operator, waiting for operator, sorry operator not available..
Their website published they hosted CIMB, wth? do you think bank will host with them with this kind of SLA? LoL, what a joke..
Finally, got their attention from facebook fanpage. Talked to their support, and got my email replied.
They should check their offline chat message if its provided on their website...
-----------------------------------------------------------------
Well, i tried to be professional in judging them.
If it wasn't because the client bought the hosting with them, i might not have to face their shit.
First, they change their hosting without our notice.
Previously things which works, now doesn't work, and they claim they never change anything,
In php point of programmer view, they disable error log.
Fine, as programmer, i will use ini_set to enable it to see what went wrong.
so my surprise, it came out error 500 instead.
so defnitely it has been disabled ini_set function... wth..
Next, if you php code doesnt close with ?>, it will also come out error 500, isn't this a norm in php to have unclosed tag? its to avoid unwanted endline charactor in the end to avoid being output out.
3rd, fine, lets fill in the support form for help..
After filling in the contact form, its been 1+ weeks and no response.
Okay, lets try call their support fella, went to voice mail...
Okay, lets try again, their "live chat",
waiting for operator, waiting for operator, waiting for operator, waiting for operator, sorry operator not available..
Their website published they hosted CIMB, wth? do you think bank will host with them with this kind of SLA? LoL, what a joke..
Subscribe to:
Posts (Atom)