将 magento 升级到 2.3.0 的 Tinytext 问题
Tinytext issue on Upgrade magento to 2.3.0
在 Magento 中,我网站的当前版本是 magento 2.2.5。现在我已经将它更新到最新版本 magento 2.3.0 。
但是当我 运行
时出现错误
php bin/magento setup:upgrade
我遇到了这个错误
Cannot process definition to array for type tinytext
请给我建议解决方案。
谢谢
您可能需要检查您的扩展程序。我自己调试了这个错误,它源于购买的主题中包含的扩展,但未更新。
是因为有些extensions.I刚刚导出数据库搜索关键字tinytext,发现一个table使用这种格式,我把它改成TEXT,问题就解决了。
您收到此错误是因为任何第三方扩展的 table 列的 "data type" 是 tinytext。
因此您需要在以下文件中使用调试找出列名。
打开这个文件/vendor/magento/framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php并检查这个fromDefinition()方法然后添加调试查找列名称的代码。
public function fromDefinition(array $data)
{
$type = $data['type'];
if (!isset($this->definitionProcessors[$type])) {
/* Add Code for Debug */
echo "<pre>";
print_r($data); exit();
/* Code End */
throw new \InvalidArgumentException(
sprintf("Cannot process definition to array for type %s", $type)
);
}
$definitionProcessor = $this->definitionProcessors[$type];
return $definitionProcessor->fromDefinition($data);
}
之后请使用 运行 setup:upgrade
命令,您将在控制台中获得列数据数组。因此,从这个数组中,您将从第三方扩展名 table.
中获取列的名称
现在 table 请将列的数据类型 "tinytext" 更改为 "text" 问题将得到解决。
注意:您可能还会遇到 ENUM 和 MEDIUMINT 数据类型的问题,因此如果遇到任何其他数据类型问题,请执行相同的步骤。
打开文件
/vendor/magento/framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
从定义中替换函数:
有:
public 函数来自定义(数组 $data)
{
$type = $data['type'];
if(in_array($type, ["tinytext", "enum"])){
$data['type'] = 'text';
$type = 'text';
}
if(in_array($type, ['time', 'mediumint'])){
$data['type'] = 'datetime';
$type = 'datetime';
}
if(in_array($type, ['mediumint'])){
$data['type'] = 'int';
$type = 'int';
}
if (!isset($this->definitionProcessors[$type])) {
throw new \InvalidArgumentException(
sprintf("Cannot process definition to array for type %s", $type)
);
}
$definitionProcessor = $this->definitionProcessors[$type];
return $definitionProcessor->fromDefinition($data);
}
在 Magento 中,我网站的当前版本是 magento 2.2.5。现在我已经将它更新到最新版本 magento 2.3.0 。 但是当我 运行
时出现错误php bin/magento setup:upgrade
我遇到了这个错误
Cannot process definition to array for type tinytext
请给我建议解决方案。 谢谢
您可能需要检查您的扩展程序。我自己调试了这个错误,它源于购买的主题中包含的扩展,但未更新。
是因为有些extensions.I刚刚导出数据库搜索关键字tinytext,发现一个table使用这种格式,我把它改成TEXT,问题就解决了。
您收到此错误是因为任何第三方扩展的 table 列的 "data type" 是 tinytext。
因此您需要在以下文件中使用调试找出列名。
打开这个文件/vendor/magento/framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php并检查这个fromDefinition()方法然后添加调试查找列名称的代码。
public function fromDefinition(array $data)
{
$type = $data['type'];
if (!isset($this->definitionProcessors[$type])) {
/* Add Code for Debug */
echo "<pre>";
print_r($data); exit();
/* Code End */
throw new \InvalidArgumentException(
sprintf("Cannot process definition to array for type %s", $type)
);
}
$definitionProcessor = $this->definitionProcessors[$type];
return $definitionProcessor->fromDefinition($data);
}
之后请使用 运行 setup:upgrade
命令,您将在控制台中获得列数据数组。因此,从这个数组中,您将从第三方扩展名 table.
现在 table 请将列的数据类型 "tinytext" 更改为 "text" 问题将得到解决。
注意:您可能还会遇到 ENUM 和 MEDIUMINT 数据类型的问题,因此如果遇到任何其他数据类型问题,请执行相同的步骤。
打开文件
/vendor/magento/framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
从定义中替换函数: 有:
public 函数来自定义(数组 $data) {
$type = $data['type'];
if(in_array($type, ["tinytext", "enum"])){
$data['type'] = 'text';
$type = 'text';
}
if(in_array($type, ['time', 'mediumint'])){
$data['type'] = 'datetime';
$type = 'datetime';
}
if(in_array($type, ['mediumint'])){
$data['type'] = 'int';
$type = 'int';
}
if (!isset($this->definitionProcessors[$type])) {
throw new \InvalidArgumentException(
sprintf("Cannot process definition to array for type %s", $type)
);
}
$definitionProcessor = $this->definitionProcessors[$type];
return $definitionProcessor->fromDefinition($data);
}