在Magento 2升级2.2.x ->2.3.2后,运行部署命令后php bin/magento setup:upgrade
出现以下错误:
......
Module 'Magento_AdvancedPricingImportExport':
Module 'Magento_Directory':
Module 'Magento_Amqp':
Type Error occurred when creating object: MagentoFrameworkCommunicationConfigData
此类存在,并且尚未件或首选项覆盖。为什么这个核心类会抛出一个问题?
所以我发现这篇文章概述了其他人,我觉得你们都磕磕绊绊。值得庆幸的是,googla 提供了对我有用的修复程序,我把它变成了一个带有偏好的漂亮模块:
<preference for="MagentoFrameworkReflectionTypeProcessor" type="MYMODULEFrameworkReflectionTypeProcessor" />
覆盖方法getParamType
:
<?php
/**
* Fix Magento 2.3.2 upgrade setup:upgrade
*
* @see https://github.com/magento/magento2/issues/22773
* @author Chris Rogers
* @since 1.0.0 <2019-08-30>
*/
namespace MYMODULEFrameworkReflection;
use MagentoFrameworkReflectionTypeProcessor as Original;
use ZendCodeReflectionParameterReflection;
use ZendCodeReflectionDocBlockTagParamTag;
class TypeProcessor extends Original
{
/**
* Get the parameter type
*
* @param ParameterReflection $param
* @return string
* @throws LogicException
*/
public function getParamType(ParameterReflection $param)
{
$type = $param->detectType();
if ($type === 'null') {
throw new LogicException(sprintf(
'@param annotation is incorrect for the parameter "%s" in the method "%s:%s".'
. ' First declared type should not be null. E.g. string|null',
$param->getName(),
$param->getDeclaringClass()->getName(),
$param->getDeclaringFunction()->name
));
}
if ($type === 'array') {
// try to determine class, if it's array of objects
$paramDocBlock = $this->getParamDocBlockTag($param);
$paramTypes = $paramDocBlock->getTypes();
$paramType = array_shift($paramTypes);
$paramType = $this->resolveFullyQualifiedClassName($param->getDeclaringClass(), $paramType);
return strpos($paramType, '[]') !== false ? $paramType : "{$paramType}[]";
}
return $type;
}
/**
* Gets method's param doc block.
*
* @param ParameterReflection $param
* @return ParamTag
*/
private function getParamDocBlockTag(ParameterReflection $param): ParamTag
{
$docBlock = $param->getDeclaringFunction()
->getDocBlock();
$paramsTag = $docBlock->getTags('param');
return $paramsTag[$param->getPosition()];
}
}
主要区别在于回报:
源语言:
返回 $this->resolveFullQualifiedClassName($param->getDeclaringClass((, $type(;
与:
返回$type;
Magento的受害者,你可以继续你的日常生活。