4

I am getting a the fatal error message below appear on random occasions:

Fatal error: Call to a member function isRequired() on a non-object in {SERVER_PATH}app/code/core/Mage/Captcha/Model/Observer.php on line 167

The fatal error takes down both the frontend and admin. The only way that I can seem to resolve the issue when it occurs is by restarting the server. After restarting the server the website can go up to 2 - 3 weeks without the issue repeating itself.

Has anybody come across this same issue before or know how it can be resolved?

  • Did you ever resolve this? I'm working with a site that has the same issue. – jsims281 Feb 3 '16 at 10:52
  • 2
    Never really got to the bottom of it unfortunately. The issue seemed to be related to some kind of cache limit on the server. Once the limit was reached the cache became invalidated causing the fatal error above. The hosting company resolved it in the end but would not disclose the exact cause so I moved the website to a different server and haven't had the problem since. Hope that helps! – Ryan Copeland Feb 4 '16 at 12:15
  • Thanks, much appreciated. It matches what we have seen so far with other people who have this issue, but I've been struggling to find any specific information about what it might be. – jsims281 Feb 4 '16 at 14:01
  • Maybe I am missing something, but how it can be related to caching? – Max Pronko Apr 15 '16 at 7:49
2

We had the same issue. I have overloaded the core method and added an additional check. Maybe this will help, if the error occurs the next time.

app/code/local/Stackexchange/CaptchaExtension/Model/Observer.php

<?php
class Stackexchange_CaptchaExtension_Model_Observer extends Mage_Captcha_Model_Observer
{
    public function checkUserLoginBackend($observer)
    {
        $formId = 'backend_login';
        $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
        $captchaModel = false;

        if (is_bool($captchaModel)) {
            // this should not happen (see Mage_Captcha_Model_Observer::checkUserLoginBackend)
            // PHP message: PHP Fatal error:  Call to a member function isRequired() on boolean in /srv/storage/www/htdocs/magento/app/code/core/Mage/Captcha/Model/Observer.php on line 167
            // so we log this!

            Mage::log(sprintf('Error during Captcha loading. Instead of model instance we got boolean "%s" in %s line %s.', $captchaModel ? 'true' : 'false', __FILE__, __LINE__), Zend_Log::DEBUG, 'system.log');
            return $this;
        }

        return parent::checkUserLoginBackend($observer);
    }
}

app/code/local/Stackexchange/CaptchaExtension/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Stackexchange_CaptchaExtension>
            <version>1.0.0</version>
        </Stackexchange_CaptchaExtension>
    </modules>
    <global>
        <models>
            <captcha>
                <rewrite>
                    <observer>Stackexchange_CaptchaExtension_Model_Observer</observer>
                </rewrite>
            </captcha>
        </models>
    </global>
</config>

app/etc/modules/Stackexchange_CaptchaExtension.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Stackexchange_CaptchaExtension>
            <active>true</active>
            <codePool>local</codePool>
        </Stackexchange_CaptchaExtension>
    </modules>
</config>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.