Magento 1.9 – Fix Notice: Undefined Variable: Block in Email Template Filter

blocksmagento-1.9supee-6788

After I have installed the following patches: SUPEE-6285-1.9.1v2, SUPEE-6482-1.9.1.1, SUPEE-6788-1.9.1.1, SUPEE-7405-1.9.1.1,
my system.log file is filled with full of the following errors:

Notice: Undefined variable: block in app/code/core/Mage/Core/Model/Email/Template/Filter.php on line 187
Notice: Undefined variable: block in app/code/core/Mage/Core/Model/Email/Template/Filter.php on line 197

How to fix the issue…

Here is the block code:

    /**
 * Retrieve Block html directive
 *
 * @param array $construction
 * @return string
 */
public function blockDirective($construction)
{
    $skipParams = array('type', 'id', 'output');
    $blockParameters = $this->_getIncludeParameters($construction[2]);
    $layout = Mage::app()->getLayout();

    if (isset($blockParameters['type'])) {
        if ($this->_permissionBlock->isTypeAllowed($blockParameters['type'])) {
            $type = $blockParameters['type'];
            $block = $layout->createBlock($type, null, $blockParameters);
        }
    } elseif (isset($blockParameters['id'])) {
        $block = $layout->createBlock('cms/block');
        if ($block) {
            $block->setBlockId($blockParameters['id']);
        }
    }

 **LINE 187**   if ($block) {
        $block->setBlockParams($blockParameters);
        foreach ($blockParameters as $k => $v) {
            if (in_array($k, $skipParams)) {
                continue;
            }
            $block->setDataUsingMethod($k, $v);
        }
    }

 **LINE 197**   if (!$block) {
        return '';
    }
    if (isset($blockParameters['output'])) {
        $method = $blockParameters['output'];
    }
    if (!isset($method) || !is_string($method) || !method_exists($block, $method)) {
        $method = 'toHtml';
    }
    return $block->$method();
}

any help would be appreciated…

Best Answer

Did you whitelist the blocks and vars in the backend?

Try to know which block to whitelist by printing debug information in app/code/core/Mage/Core/Model/Email/Template/Filter.php

If not try the following:

DON'T TRY OTHER COMMANDS UNLESS YOU REALLY KNOW WHAT YOU DO AS IT MAY BREAK YOUR WHOLE INSTALLATION!

Related Topic