Magento backend cannot log in Fatal error getBlockName

Work on Magento 1.8

I copied to the test site, but I could not log in to the backend, and this is an error message.

Fatal error: Call to a member function getBlockName() on a non-object in /var/www/test/app/code/core/Mage/Captcha/Block/Captcha.php on line 43 

To solve this problem, we usually delete the var/cache folder, but the problem on this test site does not have the var folder, so I'm not sure what causes the error.

Here's a link

+1
source share
2 answers

It looks like your code assumes that there is a class of blocks, and uses an instance of this class, and then calls the getBlockName() function.

 class Mage_Captcha_Block_Captcha extends Mage_Core_Block_Template { /** * Renders captcha HTML (if required) * * @return string */ protected function _toHtml() { $blockPath = Mage::helper('captcha')->getCaptcha($this->getFormId())->getBlockName(); 

is the code that creates the problems.

If you look at this line: getCaptcha($this->getFormId())

this should have returned an instance of the block, but for some reason he did not.

So, you need to check the Magento logs and debug why getCaptcha($this->getFormId()) did not generate the block.

+1
source

For me, the problem was that Mage::helper('captcha')->getCaptcha($this->getFormId()) did not return the class it should have. It turned out that the app/code/core/Mage/Captcha/Helper/Data.php getCaptcha did not return the model because $this->getConfigNode('type') returned NULL . This turned out to be a problem with my cache. We use both file caches in var/cache , as well as in Redis. As soon as I cleared all the caches, this problem disappeared.

By the way, $this->getConfigNode('type') trying to get the configuration value for admin/captcha/type or customer/captcha/type , none of which you will find in the core_config_data table in the database. They are actually installed in app/code/core/Mage/Captcha/etc/config.xml .

+1
source

Source: https://habr.com/ru/post/950738/


All Articles