Bugfix - Magento 1: PHP message: PHP Fatal error: Call to a member function isRequired() on a non-object in app/code/core/Mage/Captcha/Model/Observer.php on line 167 Print

  • 1

This is a bug in Magento versions < 1.9.2.0. It can exhibit as a WPoD (White Page of Death), produce a 502 error when using CloudFlare or even redirect your visitors to the Magento installation / setup wizard page. This bug only seems to occur on Magento versions earlier than 1.9.2.0 (even if patches are applied) and on servers using PHP-FPM.

Error

You should see a full error similar to the following in your proxy_error_log:

2017/01/01 01:01:00 [error] 6604#0: *992121 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function isRequired() on a non-object in /var/www/vhosts/example.co.nz/httpdocs/app/code/core/Mage/Captcha/Model/Observer.php on line 167" while reading response header from upstream, client: 192.168.1.1, server: example.co.nz, request: "GET /rss/catalog/review/ HTTP/1.1", upstream: "fastcgi://unix:/var/www/vhosts/system/example.co.nz/php-fpm.sock:", host: "www.example.co.nz"

Resolution

This is a well known problem and is already fixed in 1.9.2.0 and higher. You can either upgrade Magento to the latest stable version or implement a workaround:

Step 1) Create a file called bootstrap.php in your app folder with the following content:

/**
* Apply workaround for the libxml PHP bugs:
* @link https://bugs.php.net/bug.php?id=62577
* @link https://bugs.php.net/bug.php?id=64938
*/
if (function_exists('libxml_disable_entity_loader')) {
libxml_disable_entity_loader(false);
}

Step 2) Edit your index.php file to include just before require_once $mageFilename;

# added to address https://bugs.php.net/bug.php?id=62577 and https://bugs.php.net/bug.php?id=64938
require MAGENTO_ROOT . '/app/bootstrap.php'; require_once $mageFilename;

Step 3) Clear your cache


Was this answer helpful?

« Back