diff --git a/vendor/magento/framework/View/Element/BlockFactory.php b/vendor/magento/framework/View/Element/BlockFactory.php index a690d6aed0dfb..84625089fa9a1 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); } /** @@ -41,10 +52,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 98cf78784070e..adfad96cd411f 100644 --- a/vendor/magento/framework/View/Layout/Generator/Block.php +++ b/vendor/magento/framework/View/Layout/Generator/Block.php @@ -270,7 +270,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 3737d86d2b1f6..d96ba1384f2d8 100644 --- a/vendor/magento/framework/Webapi/ErrorProcessor.php +++ b/vendor/magento/framework/Webapi/ErrorProcessor.php @@ -46,6 +46,12 @@ class ErrorProcessor /**#@-*/ /**#@-*/ + + /** + * @var string + */ + private const REPORT_EXECUTION_GUARD = ''; + protected $encoder; /** @@ -322,7 +328,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; } }