Skip to content

Commit 37edae1

Browse files
committed
Fix getBlockSingleton
1 parent 4586539 commit 37edae1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,15 @@ public function getMessagesBlock()
595595
public function getBlockSingleton($type)
596596
{
597597
if (!isset($this->_helpers[$type])) {
598-
$helper = $this->_getBlockInstance($type);
599-
$helper->setLayout($this);
598+
$className = Mage::getConfig()->getBlockClassName($type);
599+
if ($className === false || !class_exists($className)) {
600+
Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $type));
601+
}
602+
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
603+
$helper = new $className();
604+
if ($helper instanceof Mage_Core_Block_Abstract) {
605+
$helper->setLayout($this);
606+
}
600607
$this->_helpers[$type] = $helper;
601608
}
602609
return $this->_helpers[$type];

0 commit comments

Comments
 (0)