关于将magento升级到2.3.0的Tinytext问题

时间:2018-11-29 13:59:31

标签: magento2

在Magento中,我的网站的当前版本是magento 2.2.5。现在,我已将其更新为最新版本的magento 2.3.0。 但是运行

时出现错误
  

php bin / magento设置:升级

我收到此错误

  

无法将定义处理为tinytext类型的数组

请给我建议解决方案。 谢谢

4 个答案:

答案 0 :(得分:4)

您收到此错误,因为任何第三方扩展的表列的“数据类型”为 tinytext

因此,您需要使用以下文件中的debug找出列名。

打开此文件 /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命令,您将在控制台中获得列数据数组。因此从此数组中,您将从第三方扩展表中获取列名。

现在从该表中将列的数据类型“ tinytext”更改为“ text”,问题将得到解决。

注意:您也可能还会从ENUM和MEDIUMINT数据类型中遇到问题,因此,如果遇到其他任何数据类型问题,请执行相同的步骤。

答案 1 :(得分:0)

您可能要检查您的扩展名。我为自己调试了此错误,该错误源自购买了主题但未更新的扩展。

答案 2 :(得分:0)

是的,因为有一些扩展,我只是导出数据库并搜索关键字tinytext,找到了使用这种格式的表,我将其更改为TEXT并解决了问题。

答案 3 :(得分:0)

打开文件

/vendor/magento/framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php

从定义中替换功能: 使用:

公共函数fromDefinition(array $ 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);

}