some Magento errors I encountered

Fri 02 November 2012
By balrok

Often errors in magento are very cryptic - when also googling doesn't solve problem it can get time-consuming. That's why I post here my errors I encountered and where I haven't found anything on the net.

extend() on a non-object in lib/Varien/Simplexml/Config.php

Fatal error: Call to a member function extend() on a non-object in lib/Varien/Simplexml/Config.php on line 600

You might have a permission (no read access) problem in one of your xml files. -> Solution chmod 777 -R *

Rest-api gives 404 errors

This was very time-consuming since I thought that I made a mistake with initializing the rest-api. So the problem was: http://127.0.0.1/api/rest was giving me a cms-404 error. The same error-page a customer gets when he clicks on a broken link.. The solution: When migrating from 1.6 to 1.7 the .htaccess file was forgotten and this line was missing directly after "RewriteEngine On":

RewriteRule ^api/rest api.php?type=rest [QSA,L]

Also you see here how to to make a test-request without urlrewriting: http://127.0.0.1/api.php?type=rest

MySQL errors

Often you see something like this:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND (main_table.website_id IN (0,0)) GROUP BY `main_table`.`id`' at line 4

To find what exactly this cause it is best to look into: lib/Zend/Db/Statement/Pdo.php and the function _execute Inside the catch(Exception){} you can add die(var_dump($this->stmt)) or die(var\_dump(debug\_backtrace()). Now you have the full query and its origin.

Error with simplexml_load_string

When you have an xml error in your layout your system log will get the warnings about this. But how to know in which file the error resides? Open:

app/code/core/Mage/Core/Model/Layout/Update.php

Add to line 444 (shortly after simplexml\_load\_string()
if (!\$fileXml && \$fileStr)
{
    die(\$filename);
}

more

No other errors yet :)

Commentaires: