diff --git a/vendor/magento/framework/View/Element/BlockFactory.php b/vendor/magento/framework/View/Element/BlockFactory.php index fa9fdbf736cf2..69f21095cb4a2 100644 --- a/vendor/magento/framework/View/Element/BlockFactory.php +++ b/vendor/magento/framework/View/Element/BlockFactory.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\View\Element; +use Magento\Framework\ObjectManager\ConfigInterface; use Magento\Framework\ObjectManagerInterface; /** @@ -20,14 +21,24 @@ class BlockFactory */ protected $objectManager; + /** + * @var ConfigInterface + */ + private $objectManagerConfig; + /** * Constructor * * @param ObjectManagerInterface $objectManager + * @param ConfigInterface|null $objectManagerConfig */ - public function __construct(ObjectManagerInterface $objectManager) - { + public function __construct( + ObjectManagerInterface $objectManager, + ?ConfigInterface $objectManagerConfig = null + ) { $this->objectManager = $objectManager; + $this->objectManagerConfig = $objectManagerConfig ?: + \Magento\Framework\App\ObjectManager::getInstance()->get(ConfigInterface::class); } /** @@ -45,10 +56,13 @@ public function __construct(ObjectManagerInterface $objectManager) public function createBlock($blockName, array $arguments = []) { $blockName = ltrim($blockName, '\\'); - $block = $this->objectManager->create($blockName, $arguments); - if (!$block instanceof BlockInterface) { + $resolvedType = $this->objectManagerConfig->getInstanceType( + $this->objectManagerConfig->getPreference($blockName) + ); + if (!is_a($resolvedType, BlockInterface::class, true)) { throw new \LogicException($blockName . ' does not implement BlockInterface'); } + $block = $this->objectManager->create($blockName, $arguments); if ($block instanceof Template) { $block->setTemplateContext($block); } diff --git a/vendor/magento/framework/View/Layout/Generator/Block.php b/vendor/magento/framework/View/Layout/Generator/Block.php index 1c020ffab1429..500c54d84b2c0 100644 --- a/vendor/magento/framework/View/Layout/Generator/Block.php +++ b/vendor/magento/framework/View/Layout/Generator/Block.php @@ -277,7 +277,7 @@ protected function getBlockInstance($block, array $arguments = []) if ($block && is_string($block)) { try { $block = $this->blockFactory->createBlock($block, $arguments); - } catch (\ReflectionException $e) { + } catch (\ReflectionException | \LogicException $e) { $this->logger->critical($e->getMessage()); } } diff --git a/vendor/magento/framework/Webapi/ErrorProcessor.php b/vendor/magento/framework/Webapi/ErrorProcessor.php index 36248b73776af..70237bab77047 100644 --- a/vendor/magento/framework/Webapi/ErrorProcessor.php +++ b/vendor/magento/framework/Webapi/ErrorProcessor.php @@ -45,6 +45,11 @@ class ErrorProcessor public const DATA_FORMAT_XML = 'xml'; + /** + * @var string + */ + private const REPORT_EXECUTION_GUARD = ''; + /** * @var \Magento\Framework\Json\Encoder $encoder */ @@ -425,7 +430,13 @@ protected function _saveFatalErrorReport($reportData) { $this->directoryWrite->create('report/api'); $reportId = abs((int)(microtime(true) * random_int(100, 1000))); - $this->directoryWrite->writeFile('report/api/' . $reportId, $this->serializer->serialize($reportData)); + if (is_string($reportData)) { + $reportData = str_replace('directoryWrite->writeFile( + 'report/api/' . $reportId, + self::REPORT_EXECUTION_GUARD . PHP_EOL . $this->serializer->serialize($reportData) + ); return $reportId; } }